How to convert Unicode characters to multibyte characters

Source: Internet
Author: User
Tags gtk
Zhu Jinchan <?xml:namespace prefix = o ns = "Urn:schemas-microsoft-com:office:office "/>

using GTK + recently, discovering GTK + is really a good thing, because GTK + is useful for plug-in programming and for writing Cross-platform DLLs (called shared libraries in Linux ). But using GTK + on a Windows platform is a matter of note that GTK + uses the Unicode character set, and if you compile on a Windows platform using multibyte character sets, then getting the GTK + function error message will be a bunch of garbled, Therefore, you should pay special attention to this problem when using the GTK + function with multibyte character set compilation.

however, I searched for some information on the Internet and realized that Unicode characters were converted to multibyte characters. The GTK + function G_module_error Displays the last error message for the plugin. Call function G_module_error Here for an example of how to use multibyte characters as Unicode characters:

  #ifdef _DEBUG    //I normally use the following code in the debugger if
				(!module)
				{

				int nlen = MultiByteToWideChar (Cp_utf8, 0, G_module_ Error (),-1, NULL, NULL);//
				LPWStr Lpwsz = new Wchar[nlen]; 

				MultiByteToWideChar (Cp_utf8, 0, G_module_error (),-1, Lpwsz, nlen);/
				int nLen1 = WideCharToMultiByte (CP_ACP, 0, LP Wsz, nlen, NULL, NULL, NULL, NULL); 

				LPSTR lpsz = new CHAR[NLEN1]; 

				WideCharToMultiByte (CP_ACP, 0, Lpwsz, Nlen, lpsz, nLen1, NULL, NULL);//conversion completed to get multibyte characters
    			OutputDebugString (lpsz);
				delete [] Lpwsz; 
				delete [] lpsz; 
				}
            #endif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.