PHP如何将中文转换为拼音】的更多相关文章

用来得到中文的首字母: 这个是将中文转换为拼音的类:charset <?php/*** 汉字转化为拼音,拼音转化为汉字**/ class charset{private $_code=array(array("a",'-20319'),array("ai",'-20317'),array("an",'-20304'),array("ang",'-20295'),array("ao",'-20292')…
项目地址:https://code.google.com/p/npinyin/ 在一个采集的程序中,为了给每个文章起一个别名,据说有很好的别名的话,对于百度.google的收录 是很有好处的.按照Seo的说明,百度的URL,可以用拼音,英文谷歌的URL,可以用英文命名.网站主要 面向国内,而且大部分是国内信息,所以觉得使用中文的拼音作为文章的别名是极好的. 这里分2个步骤来做的,第一步主要是把采集的文章名字取出关键字来,这个另列文章说明吧.其实也没啥大不了的, 就是用盘古分词,是一个中英文分词组…
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…
Mono 3.2 测试NPinyin 中文转换拼音代码   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[]…
一.简介 有时候,须要将汉字编程相应的拼音.以方便数据的处理.比方在Android手机应用的开发上.要查询联系人的姓名.通常都是用拼音进行查询的. 比方要查询"曹孟德",就能够输入"cmd",即"曹孟德"三个汉字的拼音"caomengde"各字的首字母.可是如何才干将"曹孟德"翻译成"caomengde"呢? 非常easy的办法就是建立一个大的对比表(比方用关联容器Map),比方<…
/** * 将汉字转换为拼音 * @author Champion.Wong * */ public class Trans2PinYin { private static int[] pyvalue = new int[] { -20319, -20317, -20304, -20295, -20292, -20283, -20265, -20257, -20242, -20230, -20051, -20036, -20032, -20026, -20002, -19990, -19986,…
在项目中经常会遇到需求用户输入汉字后转换为拼音的场景,比如说通讯录,就会要求按名字首字符发音排序,如果自己写实现这方面的功能是个很好大的工程,还好网上有公开的第三方jar支持转换,结合网上很多前辈的代码,copy了两个简单的工具方法,供参考 第一个是使用pinyin4j的jar,此jar对多音字语句的处理不太理想 package com.lovo.utils; import org.springframework.stereotype.Component; import net.sourcefo…
//php获取中文字符拼音首字母 function getFirstCharter($str){ if(empty($str)){return '';} $fchar=ord($str{}); }); $s1=iconv('UTF-8','gb2312',$str); $s2=iconv('gb2312','UTF-8',$s1); $s=$s2==$str?$s1:$str; $asc=ord($s{})*+ord($s{})-; &&$asc<=-) return 'A'; &a…
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace SU { /// <summary> /// 中文转拼音 /// </summary> public class PinYin { #region 字符集 private static readonly string[] _charIndex = new string[] { "1&…
SQL 用中文的拼音和笔画排序   城市按拼音排序: SELECT chineseName FROM [表名] order by chinesename collate Chinese_PRC_CS_AS_KS_WS asc 城市按笔划排序: SELECT chineseName FROM [表名] order by chinesename collate Chinese_PRC_Stroke_CS_AS_KS_WS   asc 以上代码中GD上调试通过. 多说两句,排序规则名称由两部份构成,前…