分享学习心得,记录学习笔记
文章:44   访问:119473
今天是:
2020年02月19日 星期三
  >   文章列表   >   文章详情
  1. //获取英文或中文首字母大写
  2. public function getCapital($s0)
  3. {
  4. $fchar = ord(mb_substr($s0,0,1));
  5. if($fchar >= ord("A") and $fchar <= ord("z") )return strtoupper($s0{0});
  6. //通过两种字符集编码转换的对比,判断字符串是哪种字符集
  7. //最终取字符串为gb的字符集
  8. $s1 = iconv("UTF-8","gb2312", $s0);
  9. $s2 = iconv("gb2312","UTF-8", $s1);
  10. $s = $s2 == $s0?$s1:$s0;
  11. $asc = ord($s{0}) * 256 + ord($s{1}) - 65536;
  12. if($asc >= -20319 and $asc <= -20284) return "A";
  13. if($asc >= -20283 and $asc <= -19776) return "B";
  14. if($asc >= -19775 and $asc <= -19219) return "C";
  15. if($asc >= -19218 and $asc <= -18711) return "D";
  16. if($asc >= -18710 and $asc <= -18527) return "E";
  17. if($asc >= -18526 and $asc <= -18240) return "F";
  18. if($asc >= -18239 and $asc <= -17923) return "G";
  19. if($asc >= -17922 and $asc <= -17418) return "H";
  20. if($asc >= -17922 and $asc <= -17418) return "I";
  21. if($asc >= -17417 and $asc <= -16475) return "J";
  22. if($asc >= -16474 and $asc <= -16213) return "K";
  23. if($asc >= -16212 and $asc <= -15641) return "L";
  24. if($asc >= -15640 and $asc <= -15166) return "M";
  25. if($asc >= -15165 and $asc <= -14923) return "N";
  26. if($asc >= -14922 and $asc <= -14915) return "O";
  27. if($asc >= -14914 and $asc <= -14631) return "P";
  28. if($asc >= -14630 and $asc <= -14150) return "Q";
  29. if($asc >= -14149 and $asc <= -14091) return "R";
  30. if($asc >= -14090 and $asc <= -13319) return "S";
  31. if($asc >= -13318 and $asc <= -12839) return "T";
  32. if($asc >= -12838 and $asc <= -12557) return "W";
  33. if($asc >= -12556 and $asc <= -11848) return "X";
  34. if($asc >= -11847 and $asc <= -11056) return "Y";
  35. if($asc >= -11055 and $asc <= -10247) return "Z";
  36. return NULL;
  37. }

友情链接 doywb

2018-2019 Copyright© 米灵尔 小熊 豫ICP备15007436号-1

豫公网安备 41152302000146号