漢字轉拼音

2022-04-08 09:52:43 字數 2959 閱讀 5572

#region 漢字轉拼音

2 3 #region 陣列資訊

4 private static int pyvalue = new int

5 6 ;

96 97 private static string pyname = new string

98 99 ;

180

181 #region 二級漢字

182 /// 183 /// 二級漢字陣列

184 ///

185 private static string otherchinese = new string

186 ;

380

381 /// 382 /// 二級漢字對應拼音陣列

383 ///

384 private static string otherpinyin = new string

385 ;

575 #endregion 二級漢字

576 #region 變數定義

577 // gb2312-80 標準規範中第乙個漢字的機內碼.即"啊"的機內碼

578 private const int firstchcode = -20319;

579 // gb2312-80 標準規範中最後乙個漢字的機內碼.即"齇"的機內碼

580 private const int lastchcode = -2050;

581 // gb2312-80 標準規範中最後乙個一級漢字的機內碼.即"座"的機內碼

582 private const int lastofonelevelchcode = -10247;

583 // 配置中文字元

584 //static regex regex = new regex("[\u4e00-\u9fa5]$");

585

586 #endregion

587 #endregion

588

589 /// 590 /// 取拼音第乙個字段

591 ///

592 ///

593 ///

594 public static string getfirst(char ch)

595

601

602 /// 603 /// 取拼音第乙個字段

604 ///

605 ///

606 ///

607 public static string getfirst(string str)

608

618

619 return sb.tostring();

620 }

621

622 /// 623 /// 獲取單字拼音

624 ///

625 ///

626 ///

627 public static string get(char ch)

628

652 // 如果是在一級漢字中

653 else if (chr <= lastofonelevelchcode)

654

672 }

673 break;

674 }

675 }

676 }

677 // 如果是在二級漢字中

678 else

679

685 }

686 #endregion 中文字元處理

687

688 //if (chr < -20319 || chr > -10247)

695

696 return string.empty;

697 }

698

699 /// 700 /// 把漢字轉換成拼音(全拼)

701 ///

702 /// 漢字字串

703 /// 轉換後的拼音(全拼)字串

704 public static string getpinyin(string str)

705

715

716 return sb.tostring();

717 }

718 #endregion

漢字轉拼音

region 漢字轉拼音 漢字轉拼音類 用法 crazycoderpinyin.covent 漢字 長度 using system.text.regularexpressions build date 20030610 public class crazycoderpinyin 定義陣列 priva...

漢字轉拼音

工具pinyin4j 2.5.0.jar 整理了3個方法,1.漢字轉拼音 2.返回中文姓 中文名 英文姓 last name 英文名 first name 3.返回首字母 public class pinyin4jdemo char hanzi word.tochararray string t2 ...

漢字轉拼音

ios mac os x 漢字轉拼音 網路流行的漢字轉拼音方案是帶乙個拼音碼表,速度快。其實core foundation也提供了一種方案,而且還帶聲調!nsmutablestring ms nsmutablestring alloc initwithstring 我是中國人 if cfstring...