I use Multibytetowidechar and Widechartomultibyte to convert utf-8
encoded string to gb2312 string ,it's work fine in 9.0 but not in 10.5
API:
function ulong WideCharToMultiByte(UINT CodePage, ulong dwFlags, ref
string lpWideCharStr, int cchWideChar, ref string lpMultiByteStr,
uint cbMultiByte,ref string lpUsedDefaultChar , ref boolean
lpUsedDefaultChar) library "Kernel32.dll " alias for
"WideCharToMultiByte;ansi"
function ulong MultiByteToWideChar(UINT CodePage, ulong dwFlags, ref
string lpMultiByteStr,int cbMultiByte, ref string lpWideCharStr ,
uint cchWideChar) library "Kernel32.dll " alias for
"MultiByteToWideChar;ansi"
--->it seems no unicode announce for Multibytetowidechar ?
-----------------------------------
//return only part string but not all in PB10.5
ULong ul_size,ul_null,ul_size2
String lb_null,m_string,w_string
String ls_null
SetNull(ls_null)
SetNull(ul_null)
SetNull(lb_null)
Boolean lb_flag = False
TRY
ul_size = multibytetowidechar(65001,0,as_utf8,-1,lb_null,0)
w_string = String(Space(ul_size))
multibytetowidechar(65001,0,as_utf8,-1,w_string,ul_size)
ul_size =
widechartomultibyte(936,ul_null,w_string,-1,lb_null,0,ls_null,lb_flag)
m_string = String(Space(ul_size))
widechartomultibyte(936,ul_null,w_string,-1,m_string,ul_size,ls_null,lb_flag)Catch(runtimeerror e) m_string = as_utf8END TRYRETURN m_string
ls_string = String(myblob, EncodingAnsi!)
"lwl" <l...@esunsoft.cn> wrote in message news:49cfb10d@forums-1-dub...
I'm writing a Email Client now using Jmail component,the data in email
is encoded with charset ,like this:
Subject:
=?utf-8?B?5Y6m6Zeo5Lq/5pif6L2v5Lu25pyJ6ZmQ5YWs5Y+4ICBBRETvvJrljqY=?=
Subject:
=?gb2312?B?MjAwNS0wOS0xNS3Stc7xsai828+1zbO5ss2syf28tqOsvPu3/s7xxvfEvw==?=
I need to conert 5Y6m6Zeo5Lq/5pif6L2v5Lu25pyJ6ZmQ5YWs5Y+4ICBBRETvvJrljqY= to
the human readable string
this convert need two steps ,firt , base64 decode ,and then convert utf-8
charset to gb2312 charset
no blob in these steps ,only asc chars .
"Roland Smith [TeamSybase]" <rsmith_at_trusthss_dot_com> 写入消息新闻:49d0b485$1@forums-1-dub...
http://www.topwizprogramming.com/freecode_winsock.html
Since you say PB9 works ok, I would change the function declarations to use
blobs instead of strings and convert the strings to blob manually, rather
than relying on ;Ansi to do it.
"lwl" <l...@esunsoft.cn> wrote in message news:49d0e9c4@forums-1-dub...
but when the email Content-Transfer-Encoding is 7bit and charset is big5
,like :
Subject: =?Big5?B?xXeq77F6pqissK27tOS3c672t3yt+6FJ?=
Content-Type: text/html; charset=Big5
Content-Transfer-Encoding: 7bit
how can i deal with this ?
can you code a funciton of_decode_7bit?
and what's the CryptStringToBinary api third parm ulong cchString mean? in
your code ,you use 1 CRYPT_STRING_BASE64 = 1
======================================================
// ---------- -------- -----------------------------------------------------
// 12/29/2006 RolandS Initial coding
// -----------------------------------------------------------------------------
Function boolean CryptStringToBinary ( &
string pszString, &
ulong cchString, &
ulong dwFlags, &
Ref blob pbBinary, &
Ref ulong pcbBinary, &
Ref ulong pdwSkip, &
Ref ulong pdwFlags &
) Library "crypt32.dll" Alias For "CryptStringToBinaryW"
-----------------------of_decode64------------------------------------
Blob lblob_data
ULong lul_len, lul_buflen, lul_skip, lul_pflags
Boolean lb_rtn
lul_len = Len(as_encoded)
lul_buflen = lul_len
lblob_data = Blob(Space(lul_len))
lb_rtn = CryptStringToBinary(as_encoded, &
lul_len, 1, lblob_data, &
lul_buflen, lul_skip, lul_pflags)
Return BlobMid(lblob_data, 1, lul_buflen)
"Roland Smith [TeamSybase]" <rsmith_at_trusthss_dot_com> 写入消息新闻:49d0ede7$1@forums-1-dub...
You might still need to use MultiByteToWideChar to handle 7-bit
http://msdn.microsoft.com/en-us/library/dd319072(VS.85).aspx
Make sure the output string argument (lpWiideCharStr) is pre-allocated
laqrge enough and cchWideChar is set to the number of spaces allocated.
"Roland Smith [TeamSybase]" <rsmith_at_trusthss_dot_com> 写入消息新闻:49d119bd$1@forums-1-dub...