汉字转拼音
来源:互联网 发布:golang 反向代理 编辑:程序博客网 时间:2024/05/01 14:28
首先,从微软官网下载Microsoft Visual Studio International Pack:http://www.microsoft.com/zh-cn/download/details.aspx?id=15251
下载后会发现有7个msi文件,我们只需要安装前两个就好:CHSPinYinConv.msi(汉字转拼音)和CHTCHSConv.msi(汉字转繁体)
安装选取默认的路径即:C:\Program Files (x86)\Microsoft Visual Studio International Pack
开始使用:
我们要先添加引用:using Microsoft.International.Converters.PinYinConverter;
using System;using System.Collections.Generic;using System.Linq;using System.Text;using Microsoft.International.Converters.PinYinConverter;using System.Collections.ObjectModel;namespace HanziZhuanpinyin{ class Program { static void Main(string[] args) { string strPin = GetPinyinByHanzi("颌").ToLower(); Console.WriteLine(strPin); Console.ReadKey(); } static string GetPinyinByHanzi(string str) { string strPin = string.Empty; foreach (char charPin in str) { ChineseChar chChar = new ChineseChar(charPin); string r = string.Empty; #region 处理多音字,IsPolyphone用来处理判断时候是多音字 if (chChar.IsPolyphone) { ReadOnlyCollection<string> pinyin = chChar.Pinyins; foreach (string pin in pinyin) { if (!String.IsNullOrEmpty(pin)) { strPin += charPin + " 汉语拼音为 " + pin.Substring(0, pin.Length - 1) + "\r\n"; } } } #endregion else { r = chChar.Pinyins[0].ToString(); strPin += r.Substring(0, r.Length - 1); } } return strPin; } }}颌 汉语拼音为 ge颌 汉语拼音为 he
- 汉字转拼音
- 汉字转拼音缩写
- 汉字转拼音缩写
- 实用汉字转拼音
- 汉字转拼音
- 汉字转拼音 asp
- 汉字转拼音缩写
- 汉字转拼音
- 汉字转拼音缩写
- 汉字转拼音
- PHP汉字转拼音
- PHP汉字转拼音
- php汉字转拼音
- java 汉字转拼音
- 汉字转拼音(C#)
- VBS 汉字转拼音
- 汉字转拼音
- 汉字转拼音
- Linux strace命令
- Linux Kernel Development 笔记(九)内核同步方法
- 一个fread失败时处理不当引发的crash
- 动态字体的贴图管理
- C#中的Base64.DecodeBase64以及Inflater解码
- 汉字转拼音
- 二维数组遍历
- Exif文件格式
- MSDE2000和SQL Server的区别
- linux awk 内置函数详细介绍(实例)
- Arnold图像变换算法
- ANT及build.xml文档编写
- 应该立长志,而不是常立志
- spring初始化配置加载