如何将Symbol字体转换为标准utf8 HTML实体 [英] How to convert Symbol font to standard utf8 HTML entity

查看:351
本文介绍了如何将Symbol字体转换为标准utf8 HTML实体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将unicode符号字体在html流中转换为等效的utf8实体?

Is there any way to convert unicode Symbol font in a html stream to its equivalent utf8 entity ?

ie。 0xf067( 作为unicode符号html实体)到希腊小字母gamma(U + 03B3 aka γ

ie. 0xf067 ( as unicode Symbol html entity) to greek small letter gamma (U+03B3 aka γ in standard utf8)

推荐答案

最后,我设法使用符号来unicode映射

Finally I managed to do it using the Symbol to unicode map at

http:/ /www.paat.auckland.ac.nz/~paul/R/CM/AdobeSym.html

然后使用iconv(如下所示)从unicode转换为utf8 unicode<> utf8)

then converting from unicode to utf8 with iconv (as unicode <> utf8)

function symbol_sanitize_string($string) {
  return preg_replace_callback('/([\x{f020}-\x{f0fe}]{1})/u', 
     'symbol_unicode_to_utf8_entity', $string);
}

function symbol_unicode_to_utf8_entity($wchar) {
  static $_SYMBOL_FONT_MAP = array (
    15696032 => 32,
    15696033 => 33,
    15696034 => 8704,
    15696035 => 35,
    15696036 => 8707,
    15696037 => 37,
    15696038 => 38,
    15696039 => 8715,
    15696040 => 40,
    15696041 => 41,
    15696042 => 8727,
    15696043 => 43,
    15696044 => 44,
    15696045 => 8722,
    15696046 => 46,
    15696047 => 47,
    15696048 => 48,
    15696049 => 49,
    15696050 => 50,
    15696051 => 51,
    15696052 => 52,
    15696053 => 53,
    15696054 => 54,
    15696055 => 55,
    15696056 => 56,
    15696057 => 57,
    15696058 => 58,
    15696059 => 59,
    15696060 => 60,
    15696061 => 61,
    15696062 => 62,
    15696063 => 63,
    15696256 => 8773,
    15696257 => 913,
    15696258 => 914,
    15696259 => 935,
    15696260 => 916,
    15696261 => 917,
    15696262 => 934,
    15696263 => 915,
    15696264 => 919,
    15696265 => 921,
    15696266 => 977,
    15696267 => 922,
    15696268 => 923,
    15696269 => 924,
    15696270 => 925,
    15696271 => 927,
    15696272 => 928,
    15696273 => 920,
    15696274 => 929,
    15696275 => 931,
    15696276 => 932,
    15696277 => 933,
    15696278 => 962,
    15696279 => 937,
    15696280 => 926,
    15696281 => 936,
    15696282 => 918,
    15696283 => 91,
    15696284 => 8756,
    15696285 => 93,
    15696286 => 8869,
    15696287 => 95,
    15696288 => 63717,
    15696289 => 945,
    15696290 => 946,
    15696291 => 967,
    15696292 => 948,
    15696293 => 949,
    15696294 => 966,
    15696295 => 947,
    15696296 => 951,
    15696297 => 953,
    15696298 => 981,
    15696299 => 954,
    15696300 => 955,
    15696301 => 956,
    15696302 => 957,
    15696303 => 959,
    15696304 => 960,
    15696305 => 952,
    15696306 => 961,
    15696307 => 963,
    15696308 => 964,
    15696309 => 965,
    15696310 => 982,
    15696311 => 969,
    15696312 => 958,
    15696313 => 968,
    15696314 => 950,
    15696315 => 123,
    15696316 => 124,
    15696317 => 125,
    15696318 => 8764,
    15696544 => 8364,
    15696545 => 978,
    15696546 => 8242,
    15696547 => 8804,
    15696548 => 8260,
    15696549 => 8734,
    15696550 => 402,
    15696551 => 9827,
    15696552 => 9830,
    15696553 => 9829,
    15696554 => 9824,
    15696555 => 8596,
    15696556 => 8592,
    15696557 => 8593,
    15696558 => 8594,
    15696559 => 8595,
    15696560 => 176,
    15696561 => 177,
    15696562 => 8243,
    15696563 => 8805,
    15696564 => 215,
    15696565 => 8733,
    15696566 => 8706,
    15696567 => 8226,
    15696568 => 247,
    15696569 => 8800,
    15696570 => 8801,
    15696571 => 8776,
    15696572 => 8230,
    15696573 => 63718,
    15696574 => 63719,
    15696575 => 8629,
    15696768 => 8501,
    15696769 => 8465,
    15696770 => 8476,
    15696771 => 8472,
    15696772 => 8855,
    15696773 => 8853,
    15696774 => 8709,
    15696775 => 8745,
    15696776 => 8746,
    15696777 => 8835,
    15696778 => 8839,
    15696779 => 8836,
    15696780 => 8834,
    15696781 => 8838,
    15696782 => 8712,
    15696783 => 8713,
    15696784 => 8736,
    15696785 => 8711,
    15696786 => 63194,
    15696787 => 63193,
    15696788 => 63195,
    15696789 => 8719,
    15696790 => 8730,
    15696791 => 8901,
    15696792 => 172,
    15696793 => 8743,
    15696794 => 8744,
    15696795 => 8660,
    15696796 => 8656,
    15696797 => 8657,
    15696798 => 8658,
    15696799 => 8659,
    15696800 => 9674,
    15696801 => 9001,
    15696802 => 63720,
    15696803 => 63721,
    15696804 => 63722,
    15696805 => 8721,
    15696806 => 63723,
    15696807 => 63724,
    15696808 => 63725,
    15696809 => 63726,
    15696810 => 63727,
    15696811 => 63728,
    15696812 => 63729,
    15696813 => 63730,
    15696814 => 63731,
    15696815 => 63732,
    15696817 => 9002,
    15696818 => 8747,
    15696819 => 8992,
    15696820 => 63733,
    15696821 => 8993,
    15696822 => 63734,
    15696823 => 63735,
    15696824 => 63736,
    15696825 => 63737,
    15696826 => 63738,
    15696827 => 63739,
    15696828 => 63740,
    15696829 => 63741,
    15696830 => 63742,
  );
  $conv = hexdec(bin2hex($wchar[1]));
  $utf8 = $_SYMBOL_FONT_MAP[$conv];    
  return $utf8 ? '&#'. $utf8 .';' : $wchar[1];
}

这篇关于如何将Symbol字体转换为标准utf8 HTML实体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆