获取汉字的拼音首字母,汉字字符串转换成以拼音首字母组成的字符串
来源:互联网 发布:源码网站哪个好 编辑:程序博客网 时间:2024/05/02 04:36
获取汉字的拼音首字母
function get_first_char($word){ $first_char = ord($word{0}); if($first_char >= ord("A") and $first_char <= ord("z") )return strtoupper($word{0}); $word_gb = iconv("UTF-8","gb2312", $word); $word_utf = iconv("gb2312","UTF-8", $word_gb); if($word_utf == $word){$s = $word_gb;}else{$s = $word;} $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;}
汉字字符串转换成以拼音首字母组成的字符串
function pinyin($zh){ $ret = ""; $word_gb = iconv("UTF-8","gb2312", $zh); $word_utf = iconv("gb2312","UTF-8", $word_gb); if($word_utf == $zh){$zh = $word_gb;} for($i = 0; $i < strlen($zh); $i++){ $word_gb = substr($zh,$i,1); $p = ord($word_gb); if($p > 160){ $word_utf = substr($zh,$i++,2); $ret .= get_first_char($word_utf); }else{ $ret .= $word_gb; } } return $ret;}
0 0
- 获取汉字的拼音首字母,汉字字符串转换成以拼音首字母组成的字符串
- vb 获取字符串汉字拼音的首字母
- 获取汉字的拼音首字母
- 获取汉字的拼音首字母
- 获取汉字的拼音首字母
- 获取汉字的拼音首字母
- 获取汉字的拼音首字母
- 获取汉字的拼音首字母
- 获取汉字的首字母拼音
- 获取拼音首字母(传入汉字字符串, 返回大写拼音首字母)
- 汉字的拼音首字母
- 获取字符串中的汉字拼音首字母
- 获取英文字符串的首字母和汉字字符串的拼音首字母
- 获得汉字字符串拼音首字母
- 获得汉字字符串拼音首字母
- 获得汉字字符串拼音首字母
- 获得汉字字符串拼音首字母 .
- 获得汉字字符串拼音首字母
- seajs模块化jQuery与jQuery插件
- 7.汽车品牌(表格分组数据)
- jarsigner签名APK包
- HTTP cookies 详解
- 如何删除在Github中创建的项目
- 获取汉字的拼音首字母,汉字字符串转换成以拼音首字母组成的字符串
- 【iOS开发-动画】CAKeyframeAnimation创建动画
- css3 linear-gradient实现按钮
- CSS 文字、段落排版
- 使用wrapper把flume做成服务优化篇
- java正则表达式 match、find匹配位置
- CSS多行文本垂直居中【转】
- SendMessage、PostMessage原理
- AngularJS资源整理收集