Results 1 to 36 of 36

Thread: [RESOLVED] Replacement for StrConv(vbFromUnicode)

Hybrid View

  1. #1

    Thread Starter
    Fanatic Member Mith's Avatar
    Join Date
    Jul 2017
    Location
    Thailand
    Posts
    540

    Re: [RESOLVED] Replacement for StrConv(vbFromUnicode)

    Quote Originally Posted by DaveDavis View Post
    StrConv Replacement? LCMapStringEx API is the core.
    I guess that StrConv internally uses the API LCMapStringEx to convert strings, or?

    My problem is that StrConv and LCMapStringEx using a language locale to convert the text and this will screw up the text on a windows system with the option for non-unicode programs set to a unicode language like chiese, russian, etc.

    example:

    i read the whole content of a small file into a byte array buffer and convert the buffer to a string:

    Code:
    hFile = CreateFileWide(sFile, GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, 0, 0)
    ReadFile(hFile, bBuffer(0), lBufferLen, lBytesRead, 0)
    sText = StrConv(bBuffer, vbUnicode)
    This code works fine on any windows system if the windows option for non-unicode programs is set to a non-unicode language like english:

    Name:  windows-language-for-non-unicode-programs-eng.jpg
Views: 2404
Size:  99.7 KB

    If the windows option for non-unicode programs is set to a unicode language like chinese some characters in the text are converted wrong:

    Name:  windows-language-for-non-unicode-programs-chinese.png
Views: 2292
Size:  34.8 KB

    Thats the reason i need a function to convert the buffer to a VBstring without using a locale language ID.
    I just want to convert the raw data from the buffer without any special language conversion.

    I guess this must be somehow possible. Maybe parsing the whole buffer by step 2 and convert every 2 bytes into a vbstring...

    I checked the encoding of the files with notepad: some are encoded with ANSI and some with UTF8.
    Last edited by Mith; Aug 10th, 2021 at 08:38 PM.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width