. Net, C # convert Chinese characters to pinyin, simplified and Traditional Chinese conversion method,

Source: Internet
Author: User

. Net, C # convert Chinese characters to pinyin, simplified and Traditional Chinese conversion method,
Visual Studio International Pack contains a set of class libraries that extend the. NET Framework support for global software development. Use the class provided by the class library ,.. NET developers can easily create software applications that support multiple cultures and languages: (1) (ChnCharInfo. dll) Simplified Chinese Pin-Yin Conversion Library-supports obtaining common attributes of Simplified Chinese characters, such as pinyin, polyphonic words, Homophone Words, and strokes. [Example :]

1 Microsoft. International. Converters. PinYinConverter. ChineseChar cc = new Microsoft. International. Converters. PinYinConverter. ChineseChar ('state ');

 

(2) (ChineseConverter. dll) Traditional Chinese to Simplified Chinese Conversion Library and Add-In Tool-supports Conversion between Simplified and Traditional Chinese. This component also contains a plug-in (Add-in) in the integrated development environment of Visual Studio that supports conversion between simplified and Traditional Chinese resource files. [Example:] -- convert Simplified Chinese to traditional Chinese
1 string temp_1 = Microsoft. International. Converters. TraditionalChineseToSimplifiedConverter. ChineseConverter. Convert );

 

-- Convert traditional Chinese characters to simplified Chinese characters
1 string temp_2 = Microsoft.International.Converters.TraditionalChineseToSimplifiedConverter.ChineseConverter.Convert(temp_1, 2  3 Microsoft.International.Converters.TraditionalChineseToSimplifiedConverter.ChineseConversionDirection.TraditionalToSimplified);

 

(3) (EastAsiaNumericFormatter. dll) East Asia Numeric Formatting Library-supports Formatting lowercase Numeric strings into uppercase Numeric strings in simplified Chinese, traditional Chinese, Japanese, and Korean. [Example:] -- converts numbers to uppercase and simplified Chinese (hundreds of millions of Chinese users have been picked up by tens of thousands of Chinese users)
1  1 string temp_4 = string.Format(new Microsoft.International.Formatters.EastAsiaNumericFormatter(), "{0:L}", 1234567890.45); 

 

-- Convert the number to lowercase (1.2 billion)
1 string temp_6 = string.Format(new Microsoft.International.Formatters.EastAsiaNumericFormatter(), "{0:Ln}", 1234567890.45);

 

-- Convert the number into a currency (hundreds of millions of yuan of data can be used to collect tens of thousands of yuan of data)
1 string temp_7 = string.Format(new Microsoft.International.Formatters.EastAsiaNumericFormatter(), "{0:Lc}", 1234567890.45);

Instance code:

// Switch string temp_1 = ChineseConverter in simplified/Traditional Chinese format. convert ("Chinese", ChineseConversionDirection. traditionalToSimplified); string temp_2 = ChineseConverter. convert ("Chinese", ChineseConversionDirection. simplifiedToTraditional); Console. writeLine ("simplified conversion:" + temp_1 + "\ n traditional conversion:" + temp_2); // converts Chinese characters to PinYin string r = string. empty; Console. write ("enter any Chinese Character:"); string str = Console. readLine (); foreach (char obj in str) {try {ChineseChar chineseChar = new ChineseChar (obj); string t = chineseChar. pinyins [0]. toString (); r + = t. substring (0, t. length-1);} catch {r + = obj. toString () ;}} Console. writeLine (r. toLower (). toString ());

Source code:

  

Result:

 

 

 

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.