I am struggling to convert a string to UTF-8
I found some code that should do this . But it does not work.
Any input is appreciated!
Code: Select all
VBSTART
Private Function StringToUTF8(String)
Dim objStream: Set objStream = CreateObject("ADODB.Stream")
Call objStream.Open()
objStream.Type = 2
objStream.Charset = "iso-8859-1"
Call objStream.WriteText(String)
objStream.Position = 0
objStream.Charset = "UTF-8"
StringToUTF8 = objStream.ReadText()
Call objStream.Close(): Set objStream = Nothing
End Function
VBEND
//res > vad
VBEval>StringToUTF8("vad"),res
//res > v
VBEval>StringToUTF8("våd"),res