tags:

views:

174

answers:

1

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?

+2  A: 

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
Helen