1. <small id='XWcLd'></small><noframes id='XWcLd'>

      <i id='XWcLd'><tr id='XWcLd'><dt id='XWcLd'><q id='XWcLd'><span id='XWcLd'><b id='XWcLd'><form id='XWcLd'><ins id='XWcLd'></ins><ul id='XWcLd'></ul><sub id='XWcLd'></sub></form><legend id='XWcLd'></legend><bdo id='XWcLd'><pre id='XWcLd'><center id='XWcLd'></center></pre></bdo></b><th id='XWcLd'></th></span></q></dt></tr></i><div id='XWcLd'><tfoot id='XWcLd'></tfoot><dl id='XWcLd'><fieldset id='XWcLd'></fieldset></dl></div>
        <bdo id='XWcLd'></bdo><ul id='XWcLd'></ul>
    2. <tfoot id='XWcLd'></tfoot>

    3. <legend id='XWcLd'><style id='XWcLd'><dir id='XWcLd'><q id='XWcLd'></q></dir></style></legend>

      我可以使用 php 获取字符的 unicode 值,反之亦然吗

      时间:2023-09-22
        <bdo id='XMFn1'></bdo><ul id='XMFn1'></ul>

            <small id='XMFn1'></small><noframes id='XMFn1'>

            <i id='XMFn1'><tr id='XMFn1'><dt id='XMFn1'><q id='XMFn1'><span id='XMFn1'><b id='XMFn1'><form id='XMFn1'><ins id='XMFn1'></ins><ul id='XMFn1'></ul><sub id='XMFn1'></sub></form><legend id='XMFn1'></legend><bdo id='XMFn1'><pre id='XMFn1'><center id='XMFn1'></center></pre></bdo></b><th id='XMFn1'></th></span></q></dt></tr></i><div id='XMFn1'><tfoot id='XMFn1'></tfoot><dl id='XMFn1'><fieldset id='XMFn1'></fieldset></dl></div>
              <tfoot id='XMFn1'></tfoot>
                <tbody id='XMFn1'></tbody>
              1. <legend id='XMFn1'><style id='XMFn1'><dir id='XMFn1'><q id='XMFn1'></q></dir></style></legend>

                本文介绍了我可以使用 php 获取字符的 unicode 值,反之亦然吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                是否可以输入一个字符并取回 unicode 值?例如,我可以将 &#12103 放在 html 中以输出⽇",是否可以将该字符作为参数提供给函数并在不构建 unicode 表的情况下获取数字作为输出?

                Is it possible to input a character and get the unicode value back? for example, i can put &#12103 in html to output "⽇", is it possible to give that character as an argument to a function and get the number as an output without building a unicode table?

                $val = someFunction("⽇");//returns 12103
                

                还是相反?

                $val2 = someOtherFunction(12103);//returns "⽇"
                

                我希望能够将实际字符而不是代码输出到页面,如果可能的话,我也希望能够从字符中获取代码.我最接近我想要的是 php.net/manual/en/function.mb-decode-numericentity.php 但我无法让它工作,这是我需要的代码还是我走错了路?

                I would like to be able to output the actual characters to the page not the codes, and I would also like to be able to get the code from the character if possible. The closest I got to what I want is php.net/manual/en/function.mb-decode-numericentity.php but I cant get it working, is this the code I need or am I on the wrong track?

                推荐答案

                function _uniord($c) {
                    if (ord($c[0]) >=0 && ord($c[0]) <= 127)
                        return ord($c[0]);
                    if (ord($c[0]) >= 192 && ord($c[0]) <= 223)
                        return (ord($c[0])-192)*64 + (ord($c[1])-128);
                    if (ord($c[0]) >= 224 && ord($c[0]) <= 239)
                        return (ord($c[0])-224)*4096 + (ord($c[1])-128)*64 + (ord($c[2])-128);
                    if (ord($c[0]) >= 240 && ord($c[0]) <= 247)
                        return (ord($c[0])-240)*262144 + (ord($c[1])-128)*4096 + (ord($c[2])-128)*64 + (ord($c[3])-128);
                    if (ord($c[0]) >= 248 && ord($c[0]) <= 251)
                        return (ord($c[0])-248)*16777216 + (ord($c[1])-128)*262144 + (ord($c[2])-128)*4096 + (ord($c[3])-128)*64 + (ord($c[4])-128);
                    if (ord($c[0]) >= 252 && ord($c[0]) <= 253)
                        return (ord($c[0])-252)*1073741824 + (ord($c[1])-128)*16777216 + (ord($c[2])-128)*262144 + (ord($c[3])-128)*4096 + (ord($c[4])-128)*64 + (ord($c[5])-128);
                    if (ord($c[0]) >= 254 && ord($c[0]) <= 255)    //  error
                        return FALSE;
                    return 0;
                }   //  function _uniord()
                

                function _unichr($o) {
                    if (function_exists('mb_convert_encoding')) {
                        return mb_convert_encoding('&#'.intval($o).';', 'UTF-8', 'HTML-ENTITIES');
                    } else {
                        return chr(intval($o));
                    }
                }   // function _unichr()
                

                这篇关于我可以使用 php 获取字符的 unicode 值,反之亦然吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:什么因素使 PHP Unicode 不兼容? 下一篇:在 PHP 5.2 中修剪 unicode 空格

                相关文章

                最新文章

                <i id='rBBxz'><tr id='rBBxz'><dt id='rBBxz'><q id='rBBxz'><span id='rBBxz'><b id='rBBxz'><form id='rBBxz'><ins id='rBBxz'></ins><ul id='rBBxz'></ul><sub id='rBBxz'></sub></form><legend id='rBBxz'></legend><bdo id='rBBxz'><pre id='rBBxz'><center id='rBBxz'></center></pre></bdo></b><th id='rBBxz'></th></span></q></dt></tr></i><div id='rBBxz'><tfoot id='rBBxz'></tfoot><dl id='rBBxz'><fieldset id='rBBxz'></fieldset></dl></div>

                  <small id='rBBxz'></small><noframes id='rBBxz'>

                  <tfoot id='rBBxz'></tfoot>
                1. <legend id='rBBxz'><style id='rBBxz'><dir id='rBBxz'><q id='rBBxz'></q></dir></style></legend>
                    <bdo id='rBBxz'></bdo><ul id='rBBxz'></ul>