//封装dll
using Microsoft.International.Converters.PinYinConverter;
using System.Text;
namespace Utils
{
public static class ChnCharInfo {
//原始
public static string ChinaCharInfoConsonant(string ToString)
{
StringBuilder SB = new StringBuilder();
foreach (char item in ToString.ToCharArray())
{
//有效
if (ChineseChar.IsValidChar(item))
{
ChineseChar China = new ChineseChar(item);
SB.Append(China.Pinyins[0]);
}
}
return SB.ToString();
}
//字母转大写去掉声调数字
public static string ChinaCharInfoUpper(string ToString)
{
StringBuilder SB = new StringBuilder();
foreach (char item in ToString.ToCharArray())
{
if (ChineseChar.IsValidChar(item))
{
ChineseChar China = new ChineseChar(item);
SB.Append(China.Pinyins[0].Substring(0,China.Pinyins[0].Length-1));
}
}
return SB.ToString();
}
//转小写
public static string ChinaCharInfoLower(string ToString)
{
StringBuilder SB = new StringBuilder();
foreach (char item in ToString.ToCharArray())
{
if (ChineseChar.IsValidChar(item))
{
ChineseChar China = new ChineseChar(item);
SB.Append(China.Pinyins[0].Substring(0, China.Pinyins[0].Length - 1).ToLower());
}
}
return SB.ToString();
}
//首字母大写
public static string ChinaCharInfoFirst(string ToString)
{
StringBuilder SB = new StringBuilder();
foreach (char item in ToString.ToCharArray())
{
if (ChineseChar.IsValidChar(item))
{
ChineseChar China = new ChineseChar(item);
string Temp = China.Pinyins[0].Substring(0, China.Pinyins[0].Length - 1);
SB.Append(Temp.Substring(0,1).ToUpper()+ (China.Pinyins[0].Substring(1, China.Pinyins[0].Length - 2)).ToLower());
}
}
return SB.ToString();
}

}
}

通过类库ChineseChar实现将汉字转化为拼音的更多相关文章

  1. C# 将汉字转化成拼音

    本文来自http://www.cnblogs.com/yazdao/archive/2011/06/04/2072488.html 首先下载Visual Studio International Pa ...

  2. c#把汉字转化成全拼音函数(全拼)

    /// <summary>        /// 把汉字转换成拼音(全拼)        /// </summary>        /// <param name=&q ...

  3. HTML5 汉字转化为拼音,带读声,穷举多音字

    1,没别的,像这种没有规则的转化,我们首先需要一个字典文件,字典文件的完整度,决定了转化的成功率与精确度 2,笔者收集了较为完整的字典文件,已上传到博客园,欢迎补充  =>  https://b ...

  4. 利用python将表格中的汉字转化为拼音

    缺少包时用pip install 进行安装,例如: pip install xlsxwriter   完成代码如下: #!/usr/bin/python #-*-coding:utf-8-*- #fr ...

  5. 将汉字转化为拼音的js插件

    /*---------------------------------------------------------------- // 文件名:chinese2pinyin.js // 文件功能描 ...

  6. 将汉字转化为拼音,正则表达式和得到汉字的Unicode编码

    一:上图,不清楚的看代码注解,很详细了 二:具体代码 窗体代码 using System; using System.Collections.Generic; using System.Compone ...

  7. react下将输入的汉字转化为拼音

    1.首先需要一个简单的拼音和汉字对应的字典文件: /** * 收录常用汉字6763个,不支持声调,支持多音字,并按照汉字使用频率由低到高排序 */ var pinyin_dict_notone = { ...

  8. js如何将汉字转化为拼音

    github地址,上面有封装好的转换工具:https://github.com/sxei/pinyinjs 里面有几个库,根据功能,库的文件大小也不一样,可以根据需求去引入使用. 里面封装好了方法: ...

  9. sql标量值函数,将汉字转化为拼音,无音标

    USE [db_Test]GO SET ANSI_NULLS ONGO SET QUOTED_IDENTIFIER ONGO create function [dbo].[fn_GetPinyin]( ...

随机推荐

  1. code blocks 安装与实践

    背景 因为不是主要修习C/C++,仅用于写算法和数据结构,code blocks轻量但是安装老是出现问题,故有此记录 安装 官方地址:http://www.codeblocks.org/downloa ...

  2. Django 命令行调用模版渲染

    首先我们需要进入 Django 的 shell python manage.py shell 渲染模版中的 name from django.template import Context,Templ ...

  3. Maven_真的需要吗?

    1.真的需要吗? Maven 是干什么用的?这是很多同学在刚开始接触 Maven 时最大的问题.之所以会提出这个问题,是因为即使不使用 Maven 我们仍然可以进行 B/S 结构项目的开发.从表述层. ...

  4. [luoguP1005] 矩阵取数游戏(DP + 高精度)

    传送门 和奶牛那个题很像,每一行状态互不影响,也就是求 n 遍DP 不过高精度非常恶心,第一次写,调了我一上午. ——代码 #include <cstdio> #include <c ...

  5. kafka streams

    https://docs.confluent.io/current/streams/concepts.html#ktable

  6. HashMap源码分析3:移除

    本文源码基于JDK1.8.0_45. final Node<K,V> removeNode(int hash, Object key, Object value, boolean matc ...

  7. 【Storage】IBM DS8100开机及配置过程

     ************************************************************************ ****原文:blog.csdn.net/cla ...

  8. Mentor.Graphics.FloTHERM.XT.2.3+Mentor.Graphics.Flowmaster.7.9.4

    Mentor.Graphics.FloTHERM.XT.2.3 Mentor.Graphics.Flowmaster.7.9.4 AVL.CRUISE.V2015.0-车辆动力学仿真分析平台 AVL. ...

  9. MVC之查询demo

    上篇已经说过怎样建立MVC项目.这次主要讲述样例的实现. 其基本的功能就是从数据库中查询一些基本信息. 前边我们已经将实体引入到了项目中,这时Model目录中已经出现了我们建立的newsSystem. ...

  10. [Vue @Component] Write Vue Functional Components Inline

    Vue's functional components are small and flexible enough to be declared inside of .vue file next to ...