How to handle UTF-8 characters in Elipse E3/Power.

Question:

How do I handle UTF-8 characters in Elipse E3/Power?

Solution:

UTF-8 characters can be handled via libraries available on the internet. However, you can also create an internal dictionary in order to handle these characters, as seen in the example below, created in a command button:

 

Sub Retangulo2_Click()


vtext = "Elipse S\u00e3o Paulo"
nStart = InStr(1,vtext,"\u")
utext = Mid(vtext, nStart, 6)

Set dicUTF = dicutf8()

ctext = dicUTF.Item(utext)

Msgbox replace(vtext,utext,ctext)

End Sub

Function dicutf8()

Set dic = CreateObject("Scripting.Dictionary")

dic.Add lcase("\u0020")," "
dic.Add lcase("\u0021"),"!"
dic.Add lcase("\u0022"),Chr(34)
dic.Add lcase("\u0023"),"#"
dic.Add lcase("\u0024"),"$"
dic.Add lcase("\u0025"),"%"
dic.Add lcase("\u0026"),"&"
dic.Add lcase("\u0027"),"'"
dic.Add lcase("\u0028"),"("
dic.Add lcase("\u0029"),")"
dic.Add lcase("\u002A"),"*"
dic.Add lcase("\u002B"),"+"
dic.Add lcase("\u002C"),"),"
dic.Add lcase("\u002D"),"-"
dic.Add lcase("\u002E"),"."
dic.Add lcase("\u002F"),"/"
dic.Add lcase("\u0030"),"0"
dic.Add lcase("\u0031"),"1"
dic.Add lcase("\u0032"),"2"
dic.Add lcase("\u0033"),"3"
dic.Add lcase("\u0034"),"4"
dic.Add lcase("\u0035"),"5"
dic.Add lcase("\u0036"),"6"
dic.Add lcase("\u0037"),"7"
dic.Add lcase("\u0038"),"8"
dic.Add lcase("\u0039"),"9"
dic.Add lcase("\u003A"),":"
dic.Add lcase("\u003B"),";"
dic.Add lcase("\u003C"),"<" 
dic.Add lcase("\u003D"),"=" 
dic.Add lcase("\u003E"),">"
dic.Add lcase("\u003F"),"?"
dic.Add lcase("\u0040"),"@"
dic.Add lcase("\u0041"),"A"
dic.Add lcase("\u0042"),"B"
dic.Add lcase("\u0043"),"C"
dic.Add lcase("\u0044"),"D"
dic.Add lcase("\u0045"),"E"
dic.Add lcase("\u0046"),"F"
dic.Add lcase("\u0047"),"G"
dic.Add lcase("\u0048"),"H"
dic.Add lcase("\u0049"),"I"
dic.Add lcase("\u004A"),"J"
dic.Add lcase("\u004B"),"K"
dic.Add lcase("\u004C"),"L"
dic.Add lcase("\u004D"),"M"
dic.Add lcase("\u004E"),"N"
dic.Add lcase("\u004F"),"O"
dic.Add lcase("\u0050"),"P"
dic.Add lcase("\u0051"),"Q"
dic.Add lcase("\u0052"),"R"
dic.Add lcase("\u0053"),"S"
dic.Add lcase("\u0054"),"T"
dic.Add lcase("\u0055"),"U"
dic.Add lcase("\u0056"),"V"
dic.Add lcase("\u0057"),"W"
dic.Add lcase("\u0058"),"X"
dic.Add lcase("\u0059"),"Y"
dic.Add lcase("\u005A"),"Z"
dic.Add lcase("\u005B"),"["
dic.Add lcase("\u005C"),"\"
dic.Add lcase("\u005D"),"]"
dic.Add lcase("\u005E"),"^"
dic.Add lcase("\u005F"),"_"
dic.Add lcase("\u0060"),"`"
dic.Add lcase("\u0061"),"a"
dic.Add lcase("\u0062"),"b"
dic.Add lcase("\u0063"),"c"
dic.Add lcase("\u0064"),"d"
dic.Add lcase("\u0065"),"e"
dic.Add lcase("\u0066"),"f"
dic.Add lcase("\u0067"),"g"
dic.Add lcase("\u0068"),"h"
dic.Add lcase("\u0069"),"i"
dic.Add lcase("\u006A"),"j"
dic.Add lcase("\u006B"),"k"
dic.Add lcase("\u006C"),"l"
dic.Add lcase("\u006D"),"m"
dic.Add lcase("\u006E"),"n"
dic.Add lcase("\u006F"),"o"
dic.Add lcase("\u0070"),"p"
dic.Add lcase("\u0071"),"q"
dic.Add lcase("\u0072"),"r"
dic.Add lcase("\u0073"),"s"
dic.Add lcase("\u0074"),"t"
dic.Add lcase("\u0075"),"u"
dic.Add lcase("\u0076"),"v"
dic.Add lcase("\u0077"),"w"
dic.Add lcase("\u0078"),"x"
dic.Add lcase("\u0079"),"y"
dic.Add lcase("\u007A"),"z"
dic.Add lcase("\u007B"),"{"
dic.Add lcase("\u007C"),"|"
dic.Add lcase("\u007D"),"}"
dic.Add lcase("\u007E"),"~"
dic.Add lcase("\u00A1"),"¡"
dic.Add lcase("\u00A2"),"¢"
dic.Add lcase("\u00A3"),"£"
dic.Add lcase("\u00A4"),"¤"
dic.Add lcase("\u00A5"),"¥"
dic.Add lcase("\u00A6"),"¦"
dic.Add lcase("\u00A7"),"§"
dic.Add lcase("\u00A8"),"¨"
dic.Add lcase("\u00A9"),"©"
dic.Add lcase("\u00AA"),"ª"
dic.Add lcase("\u00AB"),"«"
dic.Add lcase("\u00AC"),"¬"
dic.Add lcase("\u00AD"),"­"
dic.Add lcase("\u00AE"),"®"
dic.Add lcase("\u00AF"),"¯"
dic.Add lcase("\u00B0"),"°"
dic.Add lcase("\u00B1"),"±"
dic.Add lcase("\u00B2"),"²"
dic.Add lcase("\u00B3"),"³"
dic.Add lcase("\u00B4"),"´"
dic.Add lcase("\u00B5"),"µ"
dic.Add lcase("\u00B6"),"¶"
dic.Add lcase("\u00B7"),"·"
dic.Add lcase("\u00B8"),"¸"
dic.Add lcase("\u00B9"),"¹"
dic.Add lcase("\u00BA"),"º"
dic.Add lcase("\u00BB"),"»"
dic.Add lcase("\u00BC"),"¼"
dic.Add lcase("\u00BD"),"½"
dic.Add lcase("\u00BE"),"¾"
dic.Add lcase("\u00BF"),"¿"
dic.Add lcase("\u00C0"),"À"
dic.Add lcase("\u00C1"),"Á"
dic.Add lcase("\u00C2"),"Â"
dic.Add lcase("\u00C3"),"Ã"
dic.Add lcase("\u00C4"),"Ä"
dic.Add lcase("\u00C5"),"Å"
dic.Add lcase("\u00C6"),"Æ"
dic.Add lcase("\u00C7"),"Ç"
dic.Add lcase("\u00C8"),"È"
dic.Add lcase("\u00C9"),"É"
dic.Add lcase("\u00CA"),"Ê"
dic.Add lcase("\u00CB"),"Ë"
dic.Add lcase("\u00CC"),"Ì"
dic.Add lcase("\u00CD"),"Í"
dic.Add lcase("\u00CE"),"Î"
dic.Add lcase("\u00CF"),"Ï"
dic.Add lcase("\u00D0"),"Ð"
dic.Add lcase("\u00D1"),"Ñ"
dic.Add lcase("\u00D2"),"Ò"
dic.Add lcase("\u00D3"),"Ó"
dic.Add lcase("\u00D4"),"Ô"
dic.Add lcase("\u00D5"),"Õ"
dic.Add lcase("\u00D6"),"Ö"
dic.Add lcase("\u00D7"),"×"
dic.Add lcase("\u00D8"),"Ø"
dic.Add lcase("\u00D9"),"Ù"
dic.Add lcase("\u00DA"),"Ú"
dic.Add lcase("\u00DB"),"Û"
dic.Add lcase("\u00DC"),"Ü"
dic.Add lcase("\u00DD"),"Ý"
dic.Add lcase("\u00DE"),"Þ"
dic.Add lcase("\u00DF"),"ß"
dic.Add lcase("\u00E0"),"à"
dic.Add lcase("\u00E1"),"á"
dic.Add lcase("\u00E2"),"â"
dic.Add lcase("\u00E3"),"ã"
dic.Add lcase("\u00E4"),"ä"
dic.Add lcase("\u00E5"),"å"
dic.Add lcase("\u00E6"),"æ"
dic.Add lcase("\u00E7"),"ç"
dic.Add lcase("\u00E8"),"è"
dic.Add lcase("\u00E9"),"é"
dic.Add lcase("\u00EA"),"ê"
dic.Add lcase("\u00EB"),"ë"
dic.Add lcase("\u00EC"),"ì"
dic.Add lcase("\u00ED"),"í"
dic.Add lcase("\u00EE"),"î"
dic.Add lcase("\u00EF"),"ï"
dic.Add lcase("\u00F0"),"ð"
dic.Add lcase("\u00F1"),"ñ"
dic.Add lcase("\u00F2"),"ò"
dic.Add lcase("\u00F3"),"ó"
dic.Add lcase("\u00F4"),"ô"
dic.Add lcase("\u00F5"),"õ"
dic.Add lcase("\u00F6"),"ö"
dic.Add lcase("\u00F7"),"÷"
dic.Add lcase("\u00F8"),"ø"
dic.Add lcase("\u00F9"),"ù"
dic.Add lcase("\u00FA"),"ú"
dic.Add lcase("\u00FB"),"û"
dic.Add lcase("\u00FC"),"ü"
dic.Add lcase("\u00FD"),"ý"
dic.Add lcase("\u00FE"),"þ"
dic.Add lcase("\u00FF"),"ÿ"

Set dicutf8 = dic

End Function

Sub dummy()
End Sub

 

Anexos:

Script para download.txt

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *