我的计算机上的代码页遇到了一个重大问题
在Text Services and Input Languages
我选择使用English (United States) - US
对于希腊语,我选择使用Greek Polytonic
当我运行我的项目时,我使用以下代码来验证字符是否已键入
Public Shared Function ValidateChar(ByVal AsciiChar As String, ByVal CharTable As String, ByVal sender As Object, ByVal e As System.EventArgs) As Boolean
Dim ConvChar As Integer = CUInt(Microsoft.VisualBasic.Asc(AsciiChar))
Dim ConvCharW As Integer = CUInt(Microsoft.VisualBasic.AscW(AsciiChar))
ValidateChar = False
Select Case CharTable
Case GrEn
Select Case ConvChar
Case 65 To 90, 97 To 122, 182, 184 To 186, 188, 190 To 254, 8
ValidateChar = True
End Select
End Function
当我输入希腊字符λ
小lambda时,ConvChar
给我数字63,当我输入英文字符c
时,它给我数字99
这里的问题不仅是找到我的电脑的字符数字;还要控制为任何计算机设置的字符。
有什么提示可以帮助我吗?
最后,我将此代码用作计算机上的解决方案:
Public Shared Function ValidateChar(ByVal AsciiChar As String, ByVal CharTable As String,
ByVal sender As Object, ByVal e As System.EventArgs) As Boolean
Dim ConvChar As Integer = CUInt(Microsoft.VisualBasic.Asc(AsciiChar))
Dim ConvCharW As Integer = CUInt(Microsoft.VisualBasic.AscW(AsciiChar))
ValidateChar = False
Select Case CharTable
Case GrEn
Select Case ConvCharW
Case 65 To 90, 97 To 122, 913 To 937, 945 To 969, 940 To 943, 972 To 974, 8147, 8163, 8
ValidateChar = True
End Select
Case GrNEn
Select Case ConvCharW
Case 48 To 57, 65 To 90, 97 To 122, 913 To 937, 945 To 969, 940 To 943, 972 To 974, 8147, 8163, 8
ValidateChar = True
End Select
End Function
但即便如此,当我的项目在另一台带有不同窗口的计算机上运行时,我还没有解决问题。
答案 0 :(得分:0)
查找System.Text.Encoding.Unicode.GetBytes()
。尝试将您的Unicode文本转换为Byte
- 虽然它会为每个字符提供两个字节的对(因为Unicode是UTF16LE)。