php将汉字转换为拼音和得到词语首字母(四)
<?php
function getfirstchar($s0){
$firstchar_ord=ord(strtoupper($s0{0}));
if (($firstchar_ord>=65 and $firstchar_ord<=91)or($firstchar_ord>=48 and $firstchar_ord<=57)) return $s0{0};
$s=iconv("UTF-8","gb2312", $s0);
$asc=ord($s{0})*256+ord($s{1})-65536;
if($asc>=-20319 and $asc<=-20284)return "A";
if($asc>=-20283 and $asc<=-19776)return "B";
if($asc>=-19775 and $asc<=-19219)return "C";
if($asc>=-19218 and $asc<=-18711)return "D";
if($asc>=-18710 and $asc<=-18527)return "E";
if($asc>=-18526 and $asc<=-18240)return "F";
if($asc>=-18239 and $asc<=-17923)return "G";
if($asc>=-17922 and $asc<=-17418)return "H";
if($asc>=-17417 and $asc<=-16475)return "J";
if($asc>=-16474 and $asc<=-16213)return "K";
if($asc>=-16212 and $asc<=-15641)return "L";
if($asc>=-15640 and $asc<=-15166)return "M";
if($asc>=-15165 and $asc<=-14923)return "N";
if($asc>=-14922 and $asc<=-14915)return "O";
if($asc>=-14914 and $asc<=-14631)return "P";
if($asc>=-14630 and $asc<=-14150)return "Q";
if($asc>=-14149 and $asc<=-14091)return "R";
if($asc>=-14090 and $asc<=-13319)return "S";
if($asc>=-13318 and $asc<=-12839)return "T";
if($asc>=-12838 and $asc<=-12557)return "W";
if($asc>=-12556 and $asc<=-11848)return "X";
if($asc>=-11847 and $asc<=-11056)return "Y";
if($asc>=-11055 and $asc<=-10247)return "Z";
return null;
}
echo getfirstchar("这个11)豪11@*航行哈哈");
php将汉字转换为拼音和得到词语首字母(四)的更多相关文章
- php将汉字转换为拼音和得到词语首字母(一)
<?php /** * 修复二分法查找方法 * 汉字拼音首字母工具类 * 注: 英文的字串:不变返回(包括数字) eg .abc123 => abc123 * 中文字符串:返回拼音首字符 ...
- php将汉字转换为拼音和得到词语首字母(三)
<?php function getfirstchar($s0){ $fchar = ord($s0{0}); if($fchar >= ord("A") and $f ...
- php将汉字转换为拼音和得到词语首字母(二)
<?php class Pinyin{ private $_outEncoding = "GB2312"; public function getPinyin($str,$p ...
- swift把汉字转换为拼音,并且截取首字母做索引用
var transformContents = CFStringCreateMutableCopy(nil, 0, "咋啊的看到回复阿斯顿发货发哦iasdifas")CFStrin ...
- Swift - 把汉字转换为拼音,并且截取首字母做索引用
var transformContents = CFStringCreateMutableCopy(nil, 0, "咋啊的看到回复阿斯顿发货发哦iasdifas") CFStri ...
- MySQL按照汉字的拼音排序、按照首字母分类
项目中有时候需要按照汉字的拼音排序,比如联系人列表.矿物分类等,有的还需要按拼音字母从A到Z分类显示. 如果存储汉字的字段编码使用的是GBK字符集,因为GBK内码编码时本身就采用了拼音排序的方法(常用 ...
- JAVA实现汉字转换为拼音 pinyin4j/JPinyin
在项目中经常会遇到需求用户输入汉字后转换为拼音的场景,比如说通讯录,就会要求按名字首字符发音排序,如果自己写实现这方面的功能是个很好大的工程,还好网上有公开的第三方jar支持转换,结合网上很多前辈的代 ...
- iOS将汉字转换为拼音
将汉字转换为拼音 - (NSString *)chineseToPinyin:(NSString *)chinese withSpace:(BOOL)withSpace { CFStringRef h ...
- 使用PinYin4j.jar将汉字转换为拼音
package com.Test.util; import net.sourceforge.pinyin4j.PinyinHelper; import net.sourceforge.pinyin4j ...
随机推荐
- 在Visual Studio中使用NuGet管理项目库
NuGet是用来管理项目中引用的各个组件插件什么什么东西的东西,最近使用以后发现对于项目引用的维护非常方便. 暂时转一篇MSDN的文章,其实这个文章的内容就够了: http://msdn.micros ...
- SolrCloud:依据Solr Wiki的译文
本文是作者依据Apache Solr Document的译文.翻译不对或者理解不到位的地方欢迎大家指正!谢谢! Nodes, Cores, Cluster and Leaders Nodes and ...
- C# 遍历枚举(枚举是目的,遍历(获取)是手段)
C# 遍历枚举 C#中,如何获取(遍历)枚举中所有的值: public enum Suits { Spades, Hearts, Clubs, Diamonds, NumSuits } priva ...
- [na][win]AD域组策略wifi自动配置
http://wenku.baidu.com/link?url=MC950wliAZNeVUJ2M6Y1VTi5faqo7kG374fyBjW57r0qyLJkBZLg5ypiql4RFywQ8q7y ...
- 【Android】20.2 视频播放
分类:C#.Android.VS2015: 创建日期:2016-03-11 一.简介 本节例子和上一节的音频播放例子相似,也是最简单的示例,比如并没有考虑视频播放过程中电话打入的情况,也没有考虑复杂的 ...
- 飘逸的python - 几行代码实现unix管道风格的函数调用
用过linux的基本知道它的管道,是将一个程序或命令的输出作为还有一个程序或命令的输入. 废话少说,以下我们看用python怎么实现unix管道风格的函数调用. #coding=utf-8 class ...
- linux io ports io memory
http://m.blog.csdn.net/article/details?id=7204458
- JavaEE各种Javadoc的下载
刚才突然发现,很多servlet的api都不熟悉,但是又没有给eclipse导入api,就google了一下 关键字,servlet api / doc 或者java ee api / doc 注意版 ...
- 友盟分享和cocos2dx符合重复duplicate symbol 解决方案
最近使用友盟分享的sdk,没想到libWechatSDK.a居然和cocos2dx的符合冲突,提示base64.o重复了. 于是到网上找了一下解决方案,基本上去除微信的base64.o即可了. 用ar ...
- __attribute__((weak, alias())))
参考gcc的reference: 弱符号: 若两个或两个以上全局符号(函数或变量名)名字一样,而其中之一声明为weak symbol(弱符号),则这些全局符号不会引发重定义错误.链接器会忽略弱符号,去 ...