【问题标题】:Tamil character using JSON php使用 JSON php 的泰米尔语字符
【发布时间】:2014-11-26 05:26:43
【问题描述】:

如何在 JSON php 中使用泰米尔语字符

<?php

    /* Author : Girija S
       Date   : 4/21/2011
       Description: To Check the Special Chars when we pass in the json server 
    */

    $text = "தமிழ் அகராதி With the exception <br>of HTML 2.0's &quot;, &amp;, &lt;, and &gt;, these entities are &#039;all&#039; <br>new<br/> in HTML 4.0 and may not be supported by old browsers. Support in recent browsers is good.The following table gives the character entity <p>reference, decimal character reference, and hexadecimal character reference for markup-significant</p> and internationalization characters\n, as well as the rendering of each in your browser. Glyphs of the characters are available at the Unicode Consortium.<p>This is some text in a paragraph.</p>";

    $text =  json_encode(utf8_encode($text));
    echo $text;
    $text =  json_decode($text);
    echo $text;
?>

【问题讨论】:

  • 请说明您的问题。
  • 我认为你不应该在那里有“utf8_encode”......只需将其删除...... json_encode 会将您的泰米尔语字符转换为转义的演示文稿,但应该在 json_decode 上再次将其转换回来!
  • 我希望英语和泰米尔语字符在同一个字符串 'தமிழ் அகராதி 除了例外'。我想使用 php 显示这个字符串。在查询中的插入、选择、比较中也使用此字符串。但仅在字符串输出中显示或插入 ??????? ???除了..如何解决它

标签: php json tamil


【解决方案1】:

"meta http-equiv="Content-Type" content="text/html; charset=UTF-8""
在标题中使用它会解决问题..
如果你想存储在数据库中,你应该
"mysql_query ("set character_set_results='utf8'"); "
查询前..
我确实喜欢这样,并且我的泰米尔金融应用程序取得了成功

【讨论】:

    【解决方案2】:
    <?php
    //Try it ... working script.. add MIME type and Font characterset in header
    header('Content-type="application/json"');
    header('charset="utf-8"');
    $text = "தமிழ் அகராதி With the exception <br>of HTML 2.0's &amp;quot;, &amp;amp;, &amp;lt;, and &amp;gt;, these entities are &amp;#039;all&amp;#039; <br>new<br/> in HTML 4.0 and may not be supported by old browsers. Support in recent browsers is good.The following table gives the character entity <p>reference, decimal character reference, and hexadecimal character reference for markup-significant</p> and internationalization characters\n, as well as the rendering of each in your browser. Glyphs of the characters are available at the Unicode Consortium.<p>This is some text in a paragraph.</p>";
    echo $text = json_encode($text);
    echo '<br/><br/><br/>******************************************************************************<br/><br/>';
    
    echo $text = json_decode($text, JSON_PRETTY_PRINT | JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP | JSON_UNESCAPED_UNICODE);
    ?>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-24
      • 2011-10-31
      • 1970-01-01
      • 2016-12-03
      • 2012-02-06
      • 2014-02-17
      相关资源
      最近更新 更多