pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

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

  2. <tfoot id='lJqeq'></tfoot>

    <legend id='lJqeq'><style id='lJqeq'><dir id='lJqeq'><q id='lJqeq'></q></dir></style></legend>

    • <bdo id='lJqeq'></bdo><ul id='lJqeq'></ul>
    <i id='lJqeq'><tr id='lJqeq'><dt id='lJqeq'><q id='lJqeq'><span id='lJqeq'><b id='lJqeq'><form id='lJqeq'><ins id='lJqeq'></ins><ul id='lJqeq'></ul><sub id='lJqeq'></sub></form><legend id='lJqeq'></legend><bdo id='lJqeq'><pre id='lJqeq'><center id='lJqeq'></center></pre></bdo></b><th id='lJqeq'></th></span></q></dt></tr></i><div class="3xg0oah" id='lJqeq'><tfoot id='lJqeq'></tfoot><dl id='lJqeq'><fieldset id='lJqeq'></fieldset></dl></div>
    1. PHP 函數 imagettftext() 和 unicode

      PHP function imagettftext() and unicode(PHP 函數 imagettftext() 和 unicode)
        <bdo id='YnxDc'></bdo><ul id='YnxDc'></ul>

          1. <tfoot id='YnxDc'></tfoot>

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

                <tbody id='YnxDc'></tbody>

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

              <legend id='YnxDc'><style id='YnxDc'><dir id='YnxDc'><q id='YnxDc'></q></dir></style></legend>
                本文介紹了PHP 函數 imagettftext() 和 unicode的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                我正在使用 PHP 函數 imagettftext() 將文本轉換為 GIF 圖像.我正在轉換的文本包含 Unicode 字符,包括日語.在我的本地機器(Ubuntu 7.10)上一切正常,但在我的網絡主機服務器上,日語字符被破壞了.什么可能導致差異?一切都應編碼為 UTF-8.

                I'm using the PHP function imagettftext() to convert text into a GIF image. The text I am converting has Unicode characters including Japanese. Everything works fine on my local machine (Ubuntu 7.10), but on my webhost server, the Japanese characters are mangled. What could be causing the difference? Everything should be encoded as UTF-8.

                虛擬主機服務器上的損壞圖像:http://www.ibeni.net/flashcards/imagetest.php

                Broken Image on webhost server: http://www.ibeni.net/flashcards/imagetest.php

                從我的本地機器復制正確的圖像:http://www.ibeni.net/flashcards/imagetest.php.gif

                Copy of correct image from my local machine: http://www.ibeni.net/flashcards/imagetest.php.gif

                從我的本地機器復制 phpinfo():http://www.ibeni.net/flashcards/phpinfo.php.html

                Copy of phpinfo() from my local machine: http://www.ibeni.net/flashcards/phpinfo.php.html

                從我的虛擬主機服務器復制 phpinfo():http://example5.nfshost.com/phpinfo

                Copy of phpinfo() from my webhost server: http://example5.nfshost.com/phpinfo

                代碼:

                mb_language('uni');
                mb_internal_encoding('UTF-8');
                
                header('Content-type: image/gif');
                
                $text = '日本語';
                $font = './Cyberbit.ttf';
                
                // Create the image
                $im = imagecreatetruecolor(160, 160);
                $white = imagecolorallocate($im, 255, 255, 255);
                $black = imagecolorallocate($im, 0, 0, 0);
                
                // Create some colors
                imagefilledrectangle($im, 0, 0, 159, 159, $white);
                
                // Add the text
                imagettftext($im, 12, 0, 20, 20, $black, $font, $text);
                imagegif($im);
                imagedestroy($im); 
                

                推薦答案

                以下是最終對我有用的解決方案:

                Here's the solution that finally worked for me:

                $text = "你好";
                // Convert UTF-8 string to HTML entities
                $text = mb_convert_encoding($text, 'HTML-ENTITIES',"UTF-8");
                // Convert HTML entities into ISO-8859-1
                $text = html_entity_decode($text,ENT_NOQUOTES, "ISO-8859-1");
                // Convert characters > 127 into their hexidecimal equivalents
                $out = "";
                for($i = 0; $i < strlen($text); $i++) {
                    $letter = $text[$i];
                    $num = ord($letter);
                    if($num>127) {
                      $out .= "&#$num;";
                    } else {
                      $out .=  $letter;
                    }
                }
                

                將字符串轉換為 HTML 實體是可行的,只是函數 imagettftext() 不接受命名實體.例如,

                Converting the string to HTML entities works except that the function imagettftext() doesn't accept named entities. For example,

                &#26085;&#26412;&#35486;
                

                沒問題,但是

                &ccedil;
                

                不是.轉換回 ISO-8859-1,將命名實體轉換回字符,但還有第二個問題.imagettftext() 不支持值大于 >127 的字符.最后的 for 循環以十六進制對這些字符進行編碼.此解決方案適用于我正在使用的文本(包括日語、中文和葡萄牙語的重音拉丁字符),但我不能 100% 確定它適用于所有情況.

                is not. Converting back to ISO-8859-1, converts the named entities back to characters, but there is a second problem. imagettftext() doesn't support characters with a value greater than >127. The final for-loop encodes these characters in hexadecimal. This solution is working for me with the text that I am using (includes Japanese, Chinese and accented latin characters for Portuguese), but I'm not 100% sure it will work in all cases.

                需要所有這些體操,因為 imagettftext() 在我的服務器上并不真正接受 UTF-8 字符串.

                All of these gymnastics are needed because imagettftext() doesn't really accept UTF-8 strings on my server.

                這篇關于PHP 函數 imagettftext() 和 unicode的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                相關文檔推薦

                MySQLi prepared statement amp; foreach loop(MySQLi準備好的語句amp;foreach 循環)
                Is mysqli_insert_id() gets record from whole server or from same user?(mysqli_insert_id() 是從整個服務器還是從同一用戶獲取記錄?)
                PHP MySQLi doesn#39;t recognize login info(PHP MySQLi 無法識別登錄信息)
                mysqli_select_db() expects exactly 2 parameters(mysqli_select_db() 需要 2 個參數)
                Php mysql pdo query: fill up variable with query result(Php mysql pdo 查詢:用查詢結果填充變量)
                MySQLI 28000/1045 Access denied for user #39;root#39;@#39;localhost#39;(MySQLI 28000/1045 用戶“root@“localhost的訪問被拒絕)

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

                <i id='N55UL'><tr id='N55UL'><dt id='N55UL'><q id='N55UL'><span id='N55UL'><b id='N55UL'><form id='N55UL'><ins id='N55UL'></ins><ul id='N55UL'></ul><sub id='N55UL'></sub></form><legend id='N55UL'></legend><bdo id='N55UL'><pre id='N55UL'><center id='N55UL'></center></pre></bdo></b><th id='N55UL'></th></span></q></dt></tr></i><div class="ac3dabf" id='N55UL'><tfoot id='N55UL'></tfoot><dl id='N55UL'><fieldset id='N55UL'></fieldset></dl></div>
                  <bdo id='N55UL'></bdo><ul id='N55UL'></ul>
                  <legend id='N55UL'><style id='N55UL'><dir id='N55UL'><q id='N55UL'></q></dir></style></legend>

                    <tfoot id='N55UL'></tfoot>
                          <tbody id='N55UL'></tbody>
                          主站蜘蛛池模板: 免费B2B信息推广发布平台 - 推发网 | 油漆辅料厂家_阴阳脚线_艺术漆厂家_内外墙涂料施工_乳胶漆专用防霉腻子粉_轻质粉刷石膏-魔法涂涂 | 假肢-假肢价格-假肢厂家-河南假肢-郑州市力康假肢矫形器有限公司 | 自动化改造_智虎机器人_灌装机_贴标机-上海圣起包装机械 | 爱佩恒温恒湿测试箱|高低温实验箱|高低温冲击试验箱|冷热冲击试验箱-您身边的模拟环境试验设备技术专家-合作热线:400-6727-800-广东爱佩试验设备有限公司 | 上海租车公司_上海包车_奔驰租赁_上海商务租车_上海谐焕租车 | 交通信号灯生产厂家_红绿灯厂家_电子警察监控杆_标志杆厂家-沃霖电子科技 | 不锈钢电动球阀_气动高压闸阀_旋塞疏水调节阀_全立阀门-来自温州工业阀门巨头企业 | 黄石东方妇产医院_黄石妇科医院哪家好_黄石无痛人流医院 | 华中线缆有限公司-电缆厂|电缆厂家|电线电缆厂家 | 硅PU球场、篮球场地面施工「水性、环保、弹性」硅PU材料生产厂家-广东中星体育公司 | 直流电能表-充电桩电能表-导轨式电能表-智能电能表-浙江科为电气有限公司 | 齿式联轴器-弹性联轴器-联轴器厂家-江苏诺兴传动联轴器制造有限公司 | 奶茶加盟,奶茶加盟店连锁品牌-甜啦啦官网 | 单机除尘器 骨架-脉冲除尘器设备生产厂家-润天环保设备 | 体坛网_体坛+_体坛周报新闻客户端| 洁净棚-洁净工作棚-无菌室-净化工程公司_北京卫护科技有限公司 | 光纤测温-荧光光纤测温系统-福州华光天锐光电科技有限公司 | 代理记账_公司起名核名_公司注册_工商注册-睿婕实业有限公司 | 精益专家 - 设备管理软件|HSE管理系统|设备管理系统|EHS安全管理系统 | 垃圾压缩设备_垃圾处理设备_智能移动式垃圾压缩设备--山东明莱环保设备有限公司 | 温州中研白癜风专科_温州治疗白癜风_温州治疗白癜风医院哪家好_温州哪里治疗白癜风 | 成都网站建设制作_高端网站设计公司「做网站送优化推广」 | 翻斗式矿车|固定式矿车|曲轨侧卸式矿车|梭式矿车|矿车配件-山东卓力矿车生产厂家 | 玻纤土工格栅_钢塑格栅_PP焊接_单双向塑料土工格栅_复合防裂布厂家_山东大庚工程材料科技有限公司 | 复合肥,化肥厂,复合肥批发,化肥代理,复合肥品牌-红四方 | 餐饮小吃技术培训-火锅串串香培训「何小胖培训」_成都点石成金[官网] | 上海防爆真空干燥箱-上海防爆冷库-上海防爆冷柜?-上海浦下防爆设备厂家? | 石油/泥浆/不锈钢防腐/砂泵/抽砂泵/砂砾泵/吸砂泵/压滤机泵 - 专业石油环保专用泵厂家 | 大倾角皮带机-皮带输送机-螺旋输送机-矿用皮带输送机价格厂家-河南坤威机械 | 钢格板|热镀锌钢格板|钢格栅板|钢格栅|格栅板-安平县昊泽丝网制品有限公司 | 断桥铝破碎机_发动机破碎机_杂铝破碎机厂家价格-皓星机械 | 有机肥设备生产制造厂家,BB掺混肥搅拌机、复合肥设备生产线,有机肥料全部加工设备多少钱,对辊挤压造粒机,有机肥造粒设备 -- 郑州程翔重工机械有限公司 | 电镀整流器_微弧氧化电源_高频电解电源_微弧氧化设备厂家_深圳开瑞节能 | 滚珠丝杆升降机_螺旋升降机_丝杠升降机-德迈传动 | 欧洲MV日韩MV国产_人妻无码一区二区三区免费_少妇被 到高潮喷出白浆av_精品少妇自慰到喷水AV网站 | 登车桥动力单元-非标液压泵站-非标液压系统-深圳市三好科技有限公司 | 游泳池设计|设备|配件|药品|吸污机-东莞市太平洋康体设施有限公司 | 内窥镜-工业内窥镜厂家【上海修远仪器仪表有限公司】 | 沈阳楼承板_彩钢板_压型钢板厂家-辽宁中盛绿建钢品股份有限公司 轴承振动测量仪电箱-轴承测振动仪器-测试仪厂家-杭州居易电气 | 昆明挖掘机修理厂_挖掘机翻新再制造-昆明聚力工程机械维修有限公司 |