Results 1 to 7 of 7

Thread: Challenge: MultiByteToWideChar

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Location
    y
    Posts
    141
    Hi All

    This function in VC++ (MultiByteToWideChar )
    i WANT TO USE THIS FUNCTION IN VB TO CONVERT uNICODE
    tO STRING bUT UTF-8
    aNY hELP
    tHANKS

    Efrat

    [email protected]

  2. #2
    Lively Member
    Join Date
    Aug 2000
    Location
    quebec
    Posts
    81

    Cool

    check : http://msdn.microsoft.com/library/ps...icode_17si.htm
    Here's the declarations
    Code:
    Private Declare Function MultiByteToWideChar Lib "kernel32" 
    _ (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" _ 
    (ByVal CodePage As Long, ByVal dwFlags As Long, _ 
    ByVal lpWideCharStr As String, ByVal cchWideChar As Long, _
    ByVal lpMultiByteStr As String, ByVal cchMultiByte As Long, _
     ByVal _lpDefaultChar As String, ByVal lpUsedDefaultChar As Long) As Long
    
    Const CP_UTF8 = 65001
    Const CP_OEMCP = 1
    Private Const CP_ACP = 0  '  default to ANSI code page
    Here's a typical call:
    Code:
    ret = MultiByteToWideChar(CP_UTF8, 0, strMByte, Len(strMByte), strWide, Len(strWide))
    hope this helps
    C/C++,Delphi,VB6,Java,PB (blech!),ASP,JSP,SQL...bla bla bla and bla
    I love deadlines. I like the whooshing sound they make as they fly by.
    —Douglas Adams

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Location
    y
    Posts
    141

    CAN YOU WRITE SAMPLE

    hI I TRY WITH THIS CODE BUT ITS LOOK
    THAT I GOT DIFFERENT SIZE OF THE STRING

  4. #4
    Lively Member
    Join Date
    Aug 2000
    Location
    quebec
    Posts
    81

    Arrow

    I'm not sure I understand your question correctly.
    Actually I'm not sure the MultiByteToWideChar function is what you really need.

    VB String type is UNICODE, supposedly UTF-16 (BSTR), based - 2 bytes per char.

    Multibyte (MBCS) strings can contain both 1 or 2 bytes.

    Can you give me an example of what you want to do exactly?
    C/C++,Delphi,VB6,Java,PB (blech!),ASP,JSP,SQL...bla bla bla and bla
    I love deadlines. I like the whooshing sound they make as they fly by.
    —Douglas Adams

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Nov 1999
    Location
    y
    Posts
    141

    thanks here is what i want

    I need to convert string in unicode to string in UTF-8 format

    For example : tomithebest is string i need to convert it to utf-8
    thanks

  6. #6
    Lively Member
    Join Date
    Aug 2000
    Location
    quebec
    Posts
    81

    Arrow

    I don't think this API function does what you want.

    They basically convert ANSI strings to Unicode and Unicode to ANSI. They don't convert Unicode UTF-16 to Unicode UTF-8.

    You should check : http://czyborra.com/utf/#UTF-8 for more
    detail and some examples in C to see how to do conversions
    between the different formats.

    But you should verify if the StrConv function doesn't do what you want.

    Hope this helps.
    C/C++,Delphi,VB6,Java,PB (blech!),ASP,JSP,SQL...bla bla bla and bla
    I love deadlines. I like the whooshing sound they make as they fly by.
    —Douglas Adams

  7. #7
    Addicted Member Eric_B's Avatar
    Join Date
    May 2001
    Location
    home sweet home
    Posts
    130
    efrat you were able to convert to utf-8?

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