久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

    • <bdo id='yT5lT'></bdo><ul id='yT5lT'></ul>

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

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

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

    2. 使用 GD ( imagettftext() ) 和 UTF-8 字符

      Working with GD ( imagettftext() ) and UTF-8 characters(使用 GD ( imagettftext() ) 和 UTF-8 字符)
        <legend id='WcdWL'><style id='WcdWL'><dir id='WcdWL'><q id='WcdWL'></q></dir></style></legend>
              • <bdo id='WcdWL'></bdo><ul id='WcdWL'></ul>

                  <tbody id='WcdWL'></tbody>
                <tfoot id='WcdWL'></tfoot>

              • <small id='WcdWL'></small><noframes id='WcdWL'>

                <i id='WcdWL'><tr id='WcdWL'><dt id='WcdWL'><q id='WcdWL'><span id='WcdWL'><b id='WcdWL'><form id='WcdWL'><ins id='WcdWL'></ins><ul id='WcdWL'></ul><sub id='WcdWL'></sub></form><legend id='WcdWL'></legend><bdo id='WcdWL'><pre id='WcdWL'><center id='WcdWL'></center></pre></bdo></b><th id='WcdWL'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='WcdWL'><tfoot id='WcdWL'></tfoot><dl id='WcdWL'><fieldset id='WcdWL'></fieldset></dl></div>
                本文介紹了使用 GD ( imagettftext() ) 和 UTF-8 字符的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                只是為了記錄 - 我在這里的第一個問題,但希望不是我在社區中的最后一個輸入.但這不是我在這里的原因.

                Just for the record - my first question here but hopefully not my last input in the community. But that's not why I'm here.

                我目前正在開發一個簡單的系統,該系統必須生成帶有文本的圖像.一切都很順利,直到我意識到 GD 無法處理像

                I'm currently developing a simple system that has to generate an image with a text on it. Everthing went well until I realised that GD cannot handle UTF-8 characters like

                ā, ?, ?, ?, ?, é

                ā, ?, ?, ?, ?, é

                等等.

                為了解決問題 - 我正在使用 imagettftext()

                為了解決我的問題,我深入谷歌搜索并返回了一些解決方案,但遺憾的是,沒有一個解決方案完全解決了我的問題.目前我正在使用我在這個線程中找到的這個腳本 - PHP 函數 imagettftext() 和 unicode

                Trying to solve my problem I dug into depths of google and some solutions were returned, none of them, sadly, solved my problem completely. Currently I'm using this script I found in this thread - PHP function imagettftext() and unicode

                private function properText($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;
                        }
                    }
                
                    return $out;
                
                }
                

                它適用于某些字符,但不是所有字符,例如,帶有變音符號的轉換不正確.

                and it works fine for some characters but not all of them, for example, a with umlaut isn't converted correctly.

                所以在這一點上,我不知道去哪里尋找什么,因為我無法預測用戶輸入.更準確地說,系統從 xml 提要中提取藝術家姓名并使用數據生成圖像(我不打算支持象形文字).

                So at this point I'm not sure where and what to look for anymore as I cannot predict the user input. To be more precise, the system is pulling artist names from an xml feed and using the data for the image generation (I'm not planning to support hieroglyphs).

                我使用 PHP 的 mb_detect_encoding() 并且我確保當前未正確顯示的所有字符都包含在我提供給 imagettftext()<的字體文件中/em>使用 windows charmap 工具檢查它的功能.

                I've made sure that the data gathered from the feed is indeed UTF-8 by using PHP's mb_detect_encoding() and I've made sure that all the characters that currently aren't displayed correctly are indded in the font file I'm feeding to the imagettftext() function by checking it with windows charmap tool.

                希望我能在這里找到答案,并提前感謝您的幫助!

                Hopefully I can find my answer here and thank you for your help in advance!

                編輯

                澄清 - 字符顯示不正確,或者更準確地說,被格式錯誤的字符替換.這是屏幕截圖 -

                To clarify - the characters are not displayed correctly, or, to be more precise, are replaced by malformed characters. Here is a screenshot -

                應該是José González"

                it should read "José González"

                編輯 No2

                對從 xml 提要檢索到的數據使用 bin2hex() 函數返回這個.

                Using bin2hex() function on data retrieved from the xml feed returns this.

                José González -> 4a6f73c3a920476f6e7ac3a16c657a
                // input -> bin2hex(input)
                

                編輯 - 已修復

                在我繼續研究的過程中,我為我的問題找到了答案,這段代碼做到了!

                As I continued my research I came up with an answer for my problem, this piece of code did it!

                $text = mb_convert_encoding($text, "HTML-ENTITIES", "UTF-8");
                $text = preg_replace('~^(&([a-zA-Z0-9]);)~',htmlentities('${1}'),$text);
                return($text); 
                

                現在所有困擾我的字符都正確顯示了!

                Now all the characters that troubled me are displayed correctly!

                推薦答案

                在我繼續研究的過程中,我找到了解決問題的答案,這段代碼做到了!

                As I continued my research I came up with an answer for my problem, this piece of code did it!

                private function properText($text){
                    $text = mb_convert_encoding($text, "HTML-ENTITIES", "UTF-8");
                    $text = preg_replace('~^(&([a-zA-Z0-9]);)~',htmlentities('${1}'),$text);
                    return($text); 
                }
                

                現在所有困擾我的角色(以及我見過的所有新角色)都正確顯示了!

                Now all the characters (and all the new ones I've seen) that troubled me are displayed correctly!

                這篇關于使用 GD ( imagettftext() ) 和 UTF-8 字符的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                Deadlock exception code for PHP, MySQL PDOException?(PHP、MySQL PDOException 的死鎖異常代碼?)
                PHP PDO MySQL scrollable cursor doesn#39;t work(PHP PDO MySQL 可滾動游標不起作用)
                PHP PDO ODBC connection(PHP PDO ODBC 連接)
                Using PDO::FETCH_CLASS with Magic Methods(使用 PDO::FETCH_CLASS 和魔術方法)
                php pdo get only one value from mysql; value that equals to variable(php pdo 只從 mysql 獲取一個值;等于變量的值)
                MSSQL PDO could not find driver(MSSQL PDO 找不到驅動程序)
              • <legend id='Au0qM'><style id='Au0qM'><dir id='Au0qM'><q id='Au0qM'></q></dir></style></legend>
                  <tfoot id='Au0qM'></tfoot>

                • <small id='Au0qM'></small><noframes id='Au0qM'>

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

                          <bdo id='Au0qM'></bdo><ul id='Au0qM'></ul>
                          主站蜘蛛池模板: 亚洲高清av| 热re99久久精品国99热观看 | 黄色骚片| 一区二区在线 | 欧美成人精品一区二区男人看 | 欧美日韩中文在线 | 国产99在线 | 欧美 | 91久久北条麻妃一区二区三区 | 欧美激情一区二区三区 | 精品亚洲一区二区 | 一区二区三区四区av | 操一草 | 四虎影视免费在线 | 亚洲va国产日韩欧美精品色婷婷 | 免费毛片在线 | 亚洲免费网址 | 一区二区精品 | 91精品国产欧美一区二区 | 久久综合一区二区 | 欧美日韩中文在线观看 | 久久久婷| 精品视频一区二区三区四区 | 精品视频99 | 国产精品视频偷伦精品视频 | 久久国产精品精品国产色婷婷 | 99精品欧美一区二区蜜桃免费 | 国产精品美女久久久久久久网站 | 亚洲精品在线视频 | 老司机免费视频 | 精品视频一区二区三区 | 日本三级电影免费观看 | 久久久久久久国产精品视频 | 欧美在线一区二区三区 | www.日本三级| 国产乱码精品一品二品 | 欧美日韩视频网站 | 久久久成人网 | 久久蜜桃av一区二区天堂 | 成人在线| 9999精品视频 | 亚洲精品久久久久久一区二区 |