. 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: