Time:11-03
CodePudding user response:
no, 'a', for example, unicode code is 4 e00, I want this
can B is equal to s type,
Option Explicit Private Declare Function MultiByteToWideChar Lib "kernel32. DLL" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As String, ByVal cchMultiByte As Long, ByVal lpWideCharStr As String, ByVal cchWideChar As Long) As Long Private Declare Function WideCharToMultiByte Lib "kernel32. DLL" (ByVal CodePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByRef lpMultiByteStr As Any, ByVal cchMultiByte As Long, ByVal lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long Private Const CP_ACP As Long=0 Private Const CP_UTF8 As Long=65001 'the Ansi plain text files can be converted into Unicode (Little Endian) text file Private Function AnsiToULE (ByVal Inputansifile As String, ByVal OutputULEfile As String) As Boolean Dim Filebyte () As Byte, the sAnsi As String, FileNumber retLen As Long, As Long Dim sUnicodeBuffer As String On the Error Resume Next 'open the Ansi text file Inputansifile FileNumber=FreeFile If Dir (Inputansifile)="" Then AnsiToULE=False: Exit Function The Open Inputansifile For Binary As # FileNumber ReDim Filebyte (LOF (FileNumber) - 1) The Get # FileNumber, Filebyte Close # FileNumber SAnsi=StrConv (Filebyte vbUnicode) 'into VB6 can display the string RetLen=MultiByteToWideChar (CP_ACP, 0, sAnsi, LenB (sAnsi), vbNullChar, 0) 'obtained after transformation needs the space size retLen SUnicodeBuffer=String $(LenB (sAnsi), vbNullChar) set the buffer size 'If retLen & gt; 0 Then RetLen=MultiByteToWideChar (CP_ACP, 0, sAnsi, LenB (sAnsi), sUnicodeBuffer, retLen) began to convert 'The Else AnsiToULE=False: Exit Function End the If 'save as Unicode (Little Endian) text file OutputULEfile If retLen & gt; 0 Then FileNumber=FreeFile If Dir (OutputULEfile) & lt;> "" Then Kill (OutputULEfile) The Open OutputULEfile For Binary As # FileNumber Put # FileNumber., & amp; HFEFF 'plus Unicode (Little Endian) file header BOM logo FFFE Put # FileNumber, sUnicodeBuffer 'save the file content Close # FileNumber AnsiToULE=True The Else AnsiToULE=False: Exit Function End the If End the Function Unicode Big Endian 'Ansi plain text files can be converted into a text file Private Function AnsiToUBE (ByVal Inputansifile As String, ByVal OutputUBEfile As String) As Boolean Dim Filebyte () As Byte, Fbyte () As Byte Dim sAnsi As String, FileNumber retLen As Long, As Long Dim sUnicodeBuffer As String Dim As Long I On the Error Resume Next 'open the Ansi text file Inputansifile FileNumber=FreeFile If Dir (Inputansifile)="" Then AnsiToUBE=False: Exit Function The Open Inputansifile For Binary As # FileNumber ReDim Filebyte (LOF (FileNumber) - 1) The Get # FileNumber, Filebyte Close # FileNumber SAnsi=StrConv (Filebyte vbUnicode) 'into VB6 can display the string RetLen=MultiByteToWideChar (CP_ACP, 0, sAnsi, LenB (sAnsi), vbNullChar, 0) 'obtained after transformation needs the space size retLen SUnicodeBuffer=String $(LenB (sAnsi), vbNullChar) set the buffer size 'If retLen & gt; 0 Then RetLen=MultiByteToWideChar (CP_ACP, 0, sAnsi, LenB (sAnsi), sUnicodeBuffer, retLen) began to convert 'The Else AnsiToUBE=False: Exit Function End the If nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
Page link:https//www.codepudding.com/Softwareengineering/76767.html