### Convert Unicode Literals to Characters

This code can be used to convert the unicode literals to characters.
' Convert unicode literals to characters.
`Sub UnescapeUnicode(s As String) As String
Dim sb As StringBuilder
sb.Initialize
Dim i As Int
Do While i < s.Length
Dim c As Char = s.CharAt(i)
If c = "\" AND i < s.Length - 1 AND s.CharAt(i + 1) = "u" Then
Dim unicode As StringBuilder
unicode.Initialize
i = i + 2
Do While i < s.Length
Dim cc As String = s.CharAt(i)
Dim n As Int = Asc(cc.ToLowerCase)
If (n >= Asc("0") AND n <= Asc("9")) OR (n >= Asc("a") AND n <= Asc("z")) Then
unicode.Append(s.CharAt(i))
Else
i = i - 1
Exit
End If
i = i + 1
Loop
sb.Append(Chr(Bit.ParseInt(unicode.ToString, 16)))
Else
sb.Append(c)
End If
i = i + 1
Loop
Return sb.ToString
End Sub`
' Test it
Log(UnescapeUnicode("this is a test \u05d3\u05df."))

Changed: 2018-05-21 17:46, Category: Strings, File: T6C255M1845.htm, ID: 1845