|
-
Oct 3rd, 2000, 12:28 AM
#1
Thread Starter
Addicted Member
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]
-
Oct 3rd, 2000, 02:31 PM
#2
Lively Member
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
-
Oct 4th, 2000, 11:43 PM
#3
Thread Starter
Addicted Member
CAN YOU WRITE SAMPLE
hI I TRY WITH THIS CODE BUT ITS LOOK
THAT I GOT DIFFERENT SIZE OF THE STRING
-
Oct 5th, 2000, 12:01 PM
#4
Lively Member
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
-
Oct 6th, 2000, 12:22 AM
#5
Thread Starter
Addicted Member
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
-
Oct 6th, 2000, 01:15 PM
#6
Lively Member
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
-
Nov 12th, 2001, 03:17 AM
#7
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|