I apologize for this stupid question. I support the old VB6 code, and I have a function that really works, but I just can not understand why it works, or why the code does not work without it.
Basically, this function reads a UTF-8 text file and displays its contents in the DHTMLEdit component. The way this happens is that it reads the entire file into a string, and then converts it from a double byte to a multibyte string using the ANSI code page, and then converts it back to double byte.
Using all of this complex mechanism forces the component to correctly display a page that has Hebrew, Arabic, Thai, and Chinese at the same time. Without using this code, the text looks like it was converted to ASCII, showing various punctuation marks where the letters were.
I dont understand what:
- Since the source file is UTF-8 and the lines of VB6 are UTF-16, why is this even necessary? Why does VB6 correctly read a line from a file without all these conversions?
- If a function is converted from broadcast to multibyte using CodePage = 0 (ANSI), will it not eliminate any characters that are not supported by the current code page? At this station, I don’t even have Chinese, Thai or Arabic. Still, this is the only way I can correctly display the DHTMLEdit control.
[the code]
Private Declare Function MultiByteToWideChar Lib "kernel32" (ByVal codePage As Long, ByVal dwFlags As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long) As Long Private Declare Function WideCharToMultiByte Lib "kernel32" (ByVal codePage As Long, ByVal dwFlags As Long, ByVal lpWideCharStr As Long, ByVal cchWideChar As Long, ByVal lpMultiByteStr As Long, ByVal cchMultiByte As Long, ByVal lpDefaultChar As Long, lpUsedDefaultChar As Long) As Long Private Declare Function GetACP Lib "kernel32" () As Long ... Open filePath For Input As
[the code]
vb6
user884248
source share