vb读取unicode编码字符(藏语)时乱码 该如何读入啊(汉语,藏语,英文混合文本)???谢谢啦
用API函数,以下是在CSDN搜到的OptionExplicitPrivateDeclareSubCopyMemoryLib"kernel32"Alias"RtlMove...
用API函数,以下是在CSDN搜到的
Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, source As Any, ByVal Length As Long)
Private Function ReadUniFile(ByVal sFile As String) As String
'没加错误处理,大家自己加吧
Dim a As Long
a = FileLen(sFile)
ReDim buff(a - 1) As Byte
ReDim buff1(a - 3) As Byte
Open sFile For Binary As #1
Get #1, , buff
Close #1
CopyMemory buff1(0), buff(2), a - 2
Dim s As String
s = StrConv(buff1, vbNarrow)
ReadUniFile = s
End Function
Private Sub Command1_Click()
Dim str As String
str = ReadUniFile(App.Path + "\12.txt")
Text1.Text = str
End Sub
试了下有问题 a = FileLen(sFile) 块显示
实时错误'5' :
无效的过程调用或参数
这下试着打开了 汉语,英语正常显示,藏语是乱码,全是????? 展开
Option Explicit
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, source As Any, ByVal Length As Long)
Private Function ReadUniFile(ByVal sFile As String) As String
'没加错误处理,大家自己加吧
Dim a As Long
a = FileLen(sFile)
ReDim buff(a - 1) As Byte
ReDim buff1(a - 3) As Byte
Open sFile For Binary As #1
Get #1, , buff
Close #1
CopyMemory buff1(0), buff(2), a - 2
Dim s As String
s = StrConv(buff1, vbNarrow)
ReadUniFile = s
End Function
Private Sub Command1_Click()
Dim str As String
str = ReadUniFile(App.Path + "\12.txt")
Text1.Text = str
End Sub
试了下有问题 a = FileLen(sFile) 块显示
实时错误'5' :
无效的过程调用或参数
这下试着打开了 汉语,英语正常显示,藏语是乱码,全是????? 展开
2个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询