从单词中删除diachritics重音符号

时间:2016-06-18 17:43:46

标签: vbscript arguments

请帮我改变此代码以接受命令行中的参数

删除重音的功能 - diachritics。

>remove_accents Dídímênsô
Didimenso

我需要像这样运行脚本:

{{1}}

1 个答案:

答案 0 :(得分:0)

The error you mention in your comment ("remove_acentos.vbs(1, 36) Erro de compilação do Microsoft VBScript: ')' esperado") is not caused by the code you published.

This

Option Explicit

Function EliminarAcentos(texto)

    Dim i, s1, s2
    s1 = "ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜàáâãäåçèéêëìíîïòóôõöùúûü"
    s2 = "AAAAAACEEEEIIIIOOOOOUUUUaaaaaaceeeeiiiiooooouuuu"
    If Len(texto) <> 0 Then
        For i = 1 To Len(s1)
            texto = Replace(texto, Mid(s1,i,1), Mid(s2,i,1))
        Next
    End If

    EliminarAcentos = texto

End Function

Dim texto : texto = "ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜàáâãäåçèéêëìíîïòóôõöùúûü"
If WScript.Arguments.Count > 0 Then texto = WScript.Arguments(0)

WScript.Echo EliminarAcentos(texto)

compiles and runs successfully - to demonstrate the use of .Arguments.