【发布时间】:2019-12-01 04:14:31
【问题描述】:
ChrW() 是否有任何替代功能/解决方案接受不在 -32768–65535 范围内的值,例如字符代码 􀂇 导致“????”。使用ChrW() 会出错
“无效的过程调用或参数”
所以我想要一个替代解决方案来将字符代码转换为实际字符。
Code:
Function HTMLDecode(sText)
Dim regEx
Dim matches
Dim match
sText = Replace(sText, """, Chr(34))
sText = Replace(sText, "<" , Chr(60))
sText = Replace(sText, ">" , Chr(62))
sText = Replace(sText, "&" , Chr(38))
sText = Replace(sText, " ", Chr(32))
Set regEx= New RegExp
With regEx
.Pattern = "&#(\d+);" 'Match html unicode escapes
.Global = True
End With
Set matches = regEx.Execute(sText)
'Iterate over matches
For Each match In matches
'For each unicode match, replace the whole match, with the ChrW of the digits.
sText = Replace(sText, match.Value, ChrW(match.SubMatches(0)))
Next
HTMLDecode = sText
End Function
【问题讨论】:
-
􀂇 是两个 UTF-16 字符,而不是一个。因此,它不能通过对
ChrW或任何其他返回Char的函数的单个调用来生成。 -
有什么办法可以将其转换回原来的形式?
-
您使用的是经典的 ASP 和 vbscript,而不是您标记问题的 ASP.NET 和 VB.NET?
-
经典 Asp。带来不便敬请谅解。我已经编辑了它
标签: unicode vbscript asp-classic unicode-escapes