The Encoding
class does not decode escape sequences, you have to do that manually by parsing the string yourself. For that matter, VB strings use UTF-16, so you do not need to use the Encoding
class at all. Simply replace characters 2-7 ("\u00fc"
) with a single &H00FC
character, replace characters 9-14 ("\u00f6"
) with a single &H00F6
character, etc and then you are done. Each \uXXXX
sequence represents a single Unicode codepoint.
Converting Unicode escaped characters (\u#### format) into UTF-8 in VBA?
Domanda
I would like to convert the special characters in "text" variable back normal in VBA!
Dim text As String
text = "Cs\u00fct\u00f6rt\u00f6k"
text = Encoding.utf8.GetString(Encoding.ASCII.GetBytes(text))
MsgBox text
'Csütörtök would be the correct result
But in the above code Excel 2013 gives me an error about "Encoding" method.. cant parse it.
It should be working just like this online converter if you put in the text value: http://www.rapidmonkey.com/unicodeconverter/reverse.jsp
Is there any good solution for this problem? A one-line code maybe? Thanks in advance!
Soluzione
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow