C#中文转换为拼音NPinyin代码  在Mono 3.2下运行正常,Spacebuilder 有使用到NPinyin组件,代码兼容性没有问题。

using System;
using System.Collections.Generic;
using System.Text;
using NPinyin; namespace NPinyinTest
{
class Program
{
static void Main(string[] args)
{
string[] maxims = new string[]{
"事常与人违,事总在人为",
"骏马是跑出来的,强兵是打出来的",
"驾驭命运的舵是奋斗。不抱有一丝幻想,不放弃一点机会,不停止一日努力。 ",
"如果惧怕前面跌宕的山岩,生命就永远只能是死水一潭",
"懦弱的人只会裹足不前,莽撞的人只能引为烧身,只有真正勇敢的人才能所向披靡"
}; string[] medicines = new string[] {
"聚维酮碘溶液",
"开塞露",
"炉甘石洗剂",
"苯扎氯铵贴",
"鱼石脂软膏",
"莫匹罗星软膏",
"红霉素软膏",
"氢化可的松软膏",
"曲安奈德软膏",
"丁苯羟酸乳膏",
"双氯芬酸二乙胺乳膏",
"冻疮膏",
"克霉唑软膏",
"特比奈芬软膏",
"酞丁安软膏",
"咪康唑软膏、栓剂",
"甲硝唑栓",
"复方莪术油栓"
}; Console.WriteLine("UTF8句子拼音:");
foreach (string s in maxims)
{
Console.WriteLine("汉字:{0}\n拼音:{1}\n", s, Pinyin.GetPinyin(s));
} Encoding gb2312 = Encoding.GetEncoding("GB2312");
Console.WriteLine("GB2312拼音简码:");
foreach (string m in medicines)
{
string s = Pinyin.ConvertEncoding(m, Encoding.UTF8, gb2312);
Console.WriteLine("药品:{0}\n简码:{1}\n", s, Pinyin.GetInitials(s, gb2312));
} Console.ReadKey();
}
}
}
Mono 3.2下的执行结果:


.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

Mono 3.2 测试NPinyin 中文转换拼音代码的更多相关文章

  1. NPinyin 中文转换拼音代码

    Mono 3.2 测试NPinyin 中文转换拼音代码   C#中文转换为拼音NPinyin代码  在Mono 3.2下运行正常,Spacebuilder 有使用到NPinyin组件,代码兼容性没有问 ...

  2. Java 中文转换拼音工具

    Java 中文转换拼音工具 /** * <html> * <body> * <P> Copyright 1994 JsonInternational</p&g ...

  3. Python中文转拼音代码(支持全拼和首字母缩写)

    本文的代码,从https://github.com/cleverdeng/pinyin.py升级得来,针对原文的代码,做了以下升级:     1 2 3 4 1.可以传入参数firstcode:如果为 ...

  4. 在QML 中用javascritpt 将中文转换拼音,可以在音标

    项目需要, 今天整理了一下.在QML调用javascrit将中文汉字转换成拼音. 感觉执行效率低.下面是主要代码. 具体代码请参考QMLPinyin 代码 ```import "./piny ...

  5. C#中文转换为拼音NPinyin代码【转】

    项目地址:https://code.google.com/p/npinyin/ 在一个采集的程序中,为了给每个文章起一个别名,据说有很好的别名的话,对于百度.google的收录 是很有好处的.按照Se ...

  6. C#汉字转拼音(npinyin)将中文转换成拼音全文或首字母

    汉字转拼音貌似一直是C#开发的一个难题,无论什么方案都有一定的bug,之前使用了两种方案. 1.Chinese2Spell.cs 一些不能识别的汉字全部转为Z 2.Microsoft Visual S ...

  7. PHP如何将中文转换为拼音

    用来得到中文的首字母: 这个是将中文转换为拼音的类:charset <?php/*** 汉字转化为拼音,拼音转化为汉字**/ class charset{private $_code=array ...

  8. PHP的UTF-8中文转拼音处理类(性能已优化至极致)

    <?php /** * PHP 汉字转拼音 * @author Jerryli(hzjerry@gmail.com) * @version V0.20140715 * @package SPFW ...

  9. php 获取中文的拼音

    注意事项: 无法识别的中文 亳:bo,如果有此字,结果为空,调用此类之前需要手动加判断 蚌:bang,beng,多音字 莞:guan 圳:zhen 儋:dan 漯:luo 濮:pu 泸:lu 衢:qu ...

随机推荐

  1. [知识笔记]Java 基本数据类型的大小、取值范围、默认值

    数据类型 大小(字节) 范围 默认值 boolean 1/8(1bit) true/false false byte 1 -128~127 (-2^7~2^7-1) 0 short 2 -32768~ ...

  2. C#基础,C#基础知识点,基础知识点迅速巩固

    一.方法(结构.数组.冒泡排序.3个参数重载) 1将string转换为int类型 Convert.ToInt32(); int.Parse() ; int.TryParse()三种方式. 2 结构:可 ...

  3. 【leetcode】Remove Nth Node From End of List

    题目简述: Given a linked list, remove the nth node from the end of list and return its head. For example ...

  4. 15.linux按键驱动程序(二)

    linux按键驱动程序 包含内容定时器延时去抖动,阻塞型设备驱动设计 一.定时器延时去抖 按键所用开关为机械弹性开关,当机械触点断开.闭合时,由于机械触点的弹性作用,开关不会马上稳定地接通或断开.因而 ...

  5. NetMQ(三): 发布订阅模式 Publisher-Subscriber

    ZeroMQ系列 之NetMQ 一:zeromq简介 二:NetMQ 请求响应模式 Request-Reply 三:NetMQ 发布订阅模式 Publisher-Subscriber 四:NetMQ ...

  6. webform文件上传、图片水印、验证码

    文件上传: 所用控件:FileUpload 使用时的思路: 1.判断用户是否选中了文件 FileUpload.FileName获取选中的文件名,判断长度,如果长度大于零就代表已经选择了文件 JS端:通 ...

  7. 前端弹出层框架layer

    http://www.layui.com/doc/modules/layer.html#layer.confirm

  8. Bug库

    netsh int tcp set global  ecn=disable C:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe ...

  9. 手持移动扫描终端 PDA移动开单系统-批发零售管理

    条码数据采集器通过扫描商品条码移动开单,实现便携式办公,伴随式销售,是我公司的一款最新便携式开单配套产品,采集器能通过WIFI无线局域网.GPRS互联网直接与主机连接,让公司业务人员能随时随地了解公司 ...

  10. Angular内置指令(二)

    目录: $rootScope,ng-app,.run(),ng-include,ng-repeat,ng-if,ng-switch,ng-init ng-show/ng-hide,ng-model,n ...