dongwei1895 2011-11-22 16:50
浏览 70

使用iconv windows-1256进行iconv编码转换

When encoding the language "UTF-8" to "windows-1256" files I notice letters to lose I do not know why

Example of the text

<?php 


$JSON = file_get_contents("http://gdata.youtube.com/feeds/api/videos?q=sUAvgNwQsaM&alt=json");


$JSON_Data = json_decode($JSON);

$title = $JSON_Data->{'feed'}->{'entry'}[0]->{'title'}->{'$t'};

    $title= iconv("UTF-8","windows-1256","$title"); 


    echo $youtube;

    ?>

If it has been deleted

iconv("UTF-8","windows-1256","$title"); 

Full text will appear and I did not encode windows-1256

How to solve this problem A text input to databases windows-1256 encoding Greetings

  • 写回答

1条回答 默认 最新

  • douzou0073 2011-12-21 16:27
    关注

    Try this: (not my code)

    $f[]="\xc2\xac";  $t[]="\x80";
    $f[]="\xd9\xbe";  $t[]="\x81";
    $f[]="\xc0\x9a";  $t[]="\x82";
    $f[]="\xc6\x92";  $t[]="\x83";
    $f[]="\xc0\x9e";  $t[]="\x84";
    $f[]="\xc0\xa6";  $t[]="\x85";
    $f[]="\xc0\xa0";  $t[]="\x86";
    $f[]="\xc0\xa1";  $t[]="\x87";
    $f[]="\xcb\x86";  $t[]="\x88";
    $f[]="\xc0\xb0";  $t[]="\x89";
    $f[]="\xd9\xb9";  $t[]="\x8a";
    $f[]="\xc0\xb9";  $t[]="\x8b";
    $f[]="\xc5\x92";  $t[]="\x8c";
    $f[]="\xda\x86";  $t[]="\x8d";
    $f[]="\xda\x98";  $t[]="\x8e";
    $f[]="\xda\x88";  $t[]="\x8f";
    $f[]="\xda\xaf";  $t[]="\x90";
    $f[]="\xc0\x98";  $t[]="\x91";
    $f[]="\xc0\x99";  $t[]="\x92";
    $f[]="\xc0\x9c";  $t[]="\x93";
    $f[]="\xc0\x9d";  $t[]="\x94";
    $f[]="\xc0\xa2";  $t[]="\x95";
    $f[]="\xc0\x93";  $t[]="\x96";
    $f[]="\xc0\x94";  $t[]="\x97";
    $f[]="\xda\xa9";  $t[]="\x98";
    $f[]="\xc4\xa2";  $t[]="\x99";
    $f[]="\xda\x91";  $t[]="\x9a";
    $f[]="\xc0\xba";  $t[]="\x9b";
    $f[]="\xc5\x93";  $t[]="\x9c";
    $f[]="\xc0\x8c";  $t[]="\x9d";
    $f[]="\xc0\x8d";  $t[]="\x9e";
    $f[]="\xda\xba";  $t[]="\x9f";
    $f[]="\xd8\x8c";  $t[]="\xa1";
    $f[]="\xda\xbe";  $t[]="\xaa";
    $f[]="\xd8\x9b";  $t[]="\xba";
    $f[]="\xd8\x9f";  $t[]="\xbf";
    $f[]="\xdb\x81";  $t[]="\xc0";
    $f[]="\xd8\xa1";  $t[]="\xc1";
    $f[]="\xd8\xa2";  $t[]="\xc2";
    $f[]="\xd8\xa3";  $t[]="\xc3";
    $f[]="\xd8\xa4";  $t[]="\xc4";
    $f[]="\xd8\xa5";  $t[]="\xc5";
    $f[]="\xd8\xa6";  $t[]="\xc6";
    $f[]="\xd8\xa7";  $t[]="\xc7";
    $f[]="\xd8\xa8";  $t[]="\xc8";
    $f[]="\xd8\xa9";  $t[]="\xc9";
    $f[]="\xd8\xaa";  $t[]="\xca";
    $f[]="\xd8\xab";  $t[]="\xcb";
    $f[]="\xd8\xac";  $t[]="\xcc";
    $f[]="\xd8\xad";  $t[]="\xcd";
    $f[]="\xd8\xae";  $t[]="\xce";
    $f[]="\xd8\xaf";  $t[]="\xcf";
    $f[]="\xd8\xb0";  $t[]="\xd0";
    $f[]="\xd8\xb1";  $t[]="\xd1";
    $f[]="\xd8\xb2";  $t[]="\xd2";
    $f[]="\xd8\xb3";  $t[]="\xd3";
    $f[]="\xd8\xb4";  $t[]="\xd4";
    $f[]="\xd8\xb5";  $t[]="\xd5";
    $f[]="\xd8\xb6";  $t[]="\xd6";
    $f[]="\xd8\xb7";  $t[]="\xd8";
    $f[]="\xd8\xb8";  $t[]="\xd9";
    $f[]="\xd8\xb9";  $t[]="\xda";
    $f[]="\xd8\xba";  $t[]="\xdb";
    $f[]="\xd9\x80";  $t[]="\xdc";
    $f[]="\xd9\x81";  $t[]="\xdd";
    $f[]="\xd9\x82";  $t[]="\xde";
    $f[]="\xd9\x83";  $t[]="\xdf";
    $f[]="\xd9\x84";  $t[]="\xe1";
    $f[]="\xd9\x85";  $t[]="\xe3";
    $f[]="\xd9\x86";  $t[]="\xe4";
    $f[]="\xd9\x87";  $t[]="\xe5";
    $f[]="\xd9\x88";  $t[]="\xe6";
    $f[]="\xd9\x89";  $t[]="\xec";
    $f[]="\xd9\x8a";  $t[]="\xed";
    $f[]="\xd9\x8b";  $t[]="\xf0";
    $f[]="\xd9\x8c";  $t[]="\xf1";
    $f[]="\xd9\x8d";  $t[]="\xf2";
    $f[]="\xd9\x8e";  $t[]="\xf3";
    $f[]="\xd9\x8f";  $t[]="\xf5";
    $f[]="\xd9\x90";  $t[]="\xf6";
    $f[]="\xd9\x91";  $t[]="\xf8";
    $f[]="\xd9\x92";  $t[]="\xfa";
    $f[]="\xc0\x8e";  $t[]="\xfd";
    $f[]="\xc0\x8f";  $t[]="\xfe";
    $f[]="\xdb\x92";  $t[]="\xff";
    
    function utf8_to_win($str) {
      global $f, $t;
      return str_replace($f, $t, $str);
    }
    
    评论

报告相同问题?

悬赏问题

  • ¥30 Unity接入微信SDK 无法开启摄像头
  • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源