I'd like to create a .properties file to be used in a Java program from a VBScript. I'm going to use some strings in languages that use characters outside the ASCII map. So, I need to replace these characters for its UTF code. This would be \u0061 for a, \u0062 fro b and so on.
Is there a way to get the UTF code for a char in VBScript?
In two of the arguments, you have opening quotation marks embedded in the string (that's what the Chr(34) represents), but no closing quote. While that's legal VBScript code, it probably won't work the way you intended.
The Chr function converts the specified ANSI character code to a character. Note: The numbers from 0 to 31 represents nonprintable ASCII codes, i.e. Chr(10) will return a linefeed character.
VBScript has the AscW
function that returns the Unicode (wide) code of the first character in the specified string.
Note that AscW
returns the character code as a decimal number, so if you need it in a specific format, you'll have to write some additional code for that (and the problem is, VBScript doesn't have decent string formatting functions). For example, if you need the code formatted as \unnnn
, you could use a function like this:
WScript.Echo ToUnicodeChar("✈") ''# \u2708
Function ToUnicodeChar(Char)
str = Hex(AscW(Char))
ToUnicodeChar = "\u" & String(4 - Len(str), "0") & str
End Function
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With