Post

big5 <-> utf8 using vc++

知其然而不知其所以然, 太糟糕了!

big5->unicode

len=MultiByteToWideChar (CP_ACP, 0, sendbuf, -1, NULL,0) ; sendwbuf=new wchar_t[iLen+1]; MultiByteToWideChar(CP_ACP, 0, sendbuf, -1, sendwbuf, iLen);

unicode->UTF-8

len=WideCharToMultiByte (CP_UTF8, 0, sendwbuf, -1, NULL,0 ,NULL, NULL); sendbuf_utf8=new char[iLen+1]; WideCharToMultiByte (CP_UTF8, 0, sendwbuf, -1, sendbuf_utf8,iLen, NULL, NULL);

參考資料: 每個軟體開發者都絕對一定要會的Unicode及字元集必備知識(沒有藉口!)

This post is licensed under CC BY 4.0 by the author.

© homedad. Some rights reserved.

Using the Chirpy theme for Jekyll.