C # simplified and traditional conversion method (kernel32.dll)

Source: Internet
Author: User
1. Using system. runtime. interopservices;

2. Import kernel32.dllCopySave

 
[Dllimport ("Kernel32.dll", Entrypoint ="Lcmapstringa")]Public Static Extern IntLcmapstring (IntLocale,IntDwmapflags,Byte[] Lpsrcstr,IntCchsrc,Byte[] Lpdeststr,IntCchdest );Const IntLcmap_simplified_chinese.0 x 02000000;Const IntLcmap_traditional_chinese.0 x 04000000;

3. SimplifiedCopySave

Private VoidBtnchs_click (ObjectSender, eventargs e ){StringSrc = txtsrctext. Text. Trim ();Byte[] Srcbyte = encoding. Default. getbytes (SRC );Byte[] Desbyte =New Byte[Srcbyte. Length]; lcmapstring (2052, lcmap_simplified_chinese, srcbyte,-1, desbyte, srcbyte. Length );StringDes = encoding. Default. getstring (desbyte); txtdestext. Text = des ;}

4. Convert to traditional ChineseCopySave

Private VoidBtncht_click (ObjectSender, eventargs e ){StringSrc = txtsrctext. Text. Trim ();Byte[] Srcbyte = encoding. Default. getbytes (SRC );Byte[] Desbyte =New Byte[Srcbyte. Length]; lcmapstring (2052, lcmap_traditional_chinese, srcbyte,-1, desbyte, srcbyte. Length );StringDes = encoding. Default. getstring (desbyte); txtdestext. Text = des ;}

5. about the previous C # simplified and traditional conversion method (Microsoft. visualBasic. DLL) A friend mentioned the problem that "yu" cannot be converted to "yu". In this article, the method has not been resolved ,:-(. The younger brother finds n documents and other people's programs, and WebService does not solve the problem either, unless the font is used. However, in Office 2003, the simple and traditional conversion add-on can be solved. Currently, I am thinking about it from this perspective. If I have any answers, I will post them for discussion with my friends.

Related Article

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.