vbscript中的字符到UTF代码

发布于 2024-08-21 05:32:12 字数 187 浏览 17 评论 0原文

我想创建一个 .properties 文件以在 VBScript 的 Java 程序中使用。我将在使用 ASCII 映射之外的字符的语言中使用一些字符串。所以,我需要将这些字符替换为其 UTF 代码。对于 a,这将是 \u0061,对于 b,这将是 \u0062,依此类推。

有没有办法在 VBScript 中获取 char 的 UTF 代码?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

网白 2024-08-28 05:32:12

VBScript 具有 AscW 函数,该函数返回指定字符串中第一个字符的 Unicode(宽)代码。

请注意,AscW 以十进制数字形式返回字符代码,因此,如果您需要特定格式的字符代码,则必须为此编写一些额外的代码(问题是,VBScript 不具有不错的字符串格式化功能)。例如,如果您需要格式为 \unnnn 的代码,则可以使用如下函数:

WScript.Echo ToUnicodeChar("✈") ''# \u2708

Function ToUnicodeChar(Char)
  str = Hex(AscW(Char))
  ToUnicodeChar = "\u" & String(4 - Len(str), "0") & str 
End Function

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文