查看完整版本: 用php实现gb2312和unicode间的编码转换

php 2007-7-14 10:20

用php实现gb2312和unicode间的编码转换

gb2312 和 unicode 间的编码转换

下面的例子是将 gb2312 转换为 "全"这种形式

php4.3.1以后的iconv函数很好用的,只是需要自己写一个uft8到unicode的转换函数
查表(gb2312.txt)也行

[color=#000000][color=#0000cc]<[/color][color=#0000cc]?[/color]
[color=#0000ff]$[/color][color=#008080]text[/color] [color=#0000cc]=[/color] [color=#ff00ff]"电子书库"[/color][color=#0000cc];[/color]
[color=#ff0000]preg_match_all[/color][color=#0000cc]([/color][color=#ff00ff]"/[\x80-\xff]?./"[/color][color=#0000cc],[/color][color=#0000ff]$[/color][color=#008080]text[/color][color=#0000cc],[/color][color=#0000ff]$[/color][color=#008080]ar[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]foreach[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]ar[/color][color=#0000cc][[/color]0[color=#0000cc]][/color] [color=#0000ff]as[/color] [color=#0000ff]$[/color][color=#008080]v[/color][color=#0000cc])[/color]
  [color=#ff0000]echo[/color] [color=#ff00ff]"&#"[/color][color=#0000cc].[/color]utf8_unicode[color=#0000cc]([/color][color=#ff0000]iconv[/color][color=#0000cc]([/color][color=#ff00ff]"GB2312"[/color][color=#0000cc],[/color][color=#ff00ff]"UTF-8"[/color][color=#0000cc],[/color][color=#0000ff]$[/color][color=#008080]v[/color][color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc].[/color][color=#ff00ff]";"[/color][color=#0000cc];[/color]
[color=#0000cc]?[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000cc]?[/color]
[color=#ff9900]// utf8 -> unicode
[/color]
[color=#0000ff]function[/color] utf8_unicode[color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc])[/color] [color=#0000cc]{[/color]
  [color=#0000ff]switch[/color][color=#0000cc]([/color][color=#ff0000]strlen[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc])[/color][color=#0000cc])[/color] [color=#0000cc]{[/color]
    [color=#0000ff]case[/color] 1[color=#0000cc]:[/color]
      [color=#0000ff]return[/color] [color=#ff0000]ord[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc])[/color][color=#0000cc];[/color]
    [color=#0000ff]case[/color] 2[color=#0000cc]:[/color]
      [color=#0000ff]$[/color][color=#008080]n[/color] [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#ff0000]ord[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc][[/color]0[color=#0000cc]][/color][color=#0000cc])[/color] [color=#0000cc]&[/color] 0x3f[color=#0000cc])[/color] [color=#0000cc]<[/color][color=#0000cc]<[/color] 6[color=#0000cc];[/color]
      [color=#0000ff]$[/color][color=#008080]n[/color] [color=#0000cc]+[/color][color=#0000cc]=[/color] [color=#ff0000]ord[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc][[/color]1[color=#0000cc]][/color][color=#0000cc])[/color] [color=#0000cc]&[/color] 0x3f[color=#0000cc];[/color]
      [color=#0000ff]return[/color] [color=#0000ff]$[/color][color=#008080]n[/color][color=#0000cc];[/color]
    [color=#0000ff]case[/color] 3[color=#0000cc]:[/color]
      [color=#0000ff]$[/color][color=#008080]n[/color] [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#ff0000]ord[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc][[/color]0[color=#0000cc]][/color][color=#0000cc])[/color] [color=#0000cc]&[/color] 0x1f[color=#0000cc])[/color] [color=#0000cc]<[/color][color=#0000cc]<[/color] 12[color=#0000cc];[/color]
      [color=#0000ff]$[/color][color=#008080]n[/color] [color=#0000cc]+[/color][color=#0000cc]=[/color] [color=#0000cc]([/color][color=#ff0000]ord[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc][[/color]1[color=#0000cc]][/color][color=#0000cc])[/color] [color=#0000cc]&[/color] 0x3f[color=#0000cc])[/color] [color=#0000cc]<[/color][color=#0000cc]<[/color] 6[color=#0000cc];[/color]
      [color=#0000ff]$[/color][color=#008080]n[/color] [color=#0000cc]+[/color][color=#0000cc]=[/color] [color=#ff0000]ord[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc][[/color]2[color=#0000cc]][/color][color=#0000cc])[/color] [color=#0000cc]&[/color] 0x3f[color=#0000cc];[/color]
      [color=#0000ff]return[/color] [color=#0000ff]$[/color][color=#008080]n[/color][color=#0000cc];[/color]
    [color=#0000ff]case[/color] 4[color=#0000cc]:[/color]
      [color=#0000ff]$[/color][color=#008080]n[/color] [color=#0000cc]=[/color] [color=#0000cc]([/color][color=#ff0000]ord[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc][[/color]0[color=#0000cc]][/color][color=#0000cc])[/color] [color=#0000cc]&[/color] 0x0f[color=#0000cc])[/color] [color=#0000cc]<[/color][color=#0000cc]<[/color] 18[color=#0000cc];[/color]
      [color=#0000ff]$[/color][color=#008080]n[/color] [color=#0000cc]+[/color][color=#0000cc]=[/color] [color=#0000cc]([/color][color=#ff0000]ord[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc][[/color]1[color=#0000cc]][/color][color=#0000cc])[/color] [color=#0000cc]&[/color] 0x3f[color=#0000cc])[/color] [color=#0000cc]<[/color][color=#0000cc]<[/color] 12[color=#0000cc];[/color]
      [color=#0000ff]$[/color][color=#008080]n[/color] [color=#0000cc]+[/color][color=#0000cc]=[/color] [color=#0000cc]([/color][color=#ff0000]ord[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc][[/color]2[color=#0000cc]][/color][color=#0000cc])[/color] [color=#0000cc]&[/color] 0x3f[color=#0000cc])[/color] [color=#0000cc]<[/color][color=#0000cc]<[/color] 6[color=#0000cc];[/color]
      [color=#0000ff]$[/color][color=#008080]n[/color] [color=#0000cc]+[/color][color=#0000cc]=[/color] [color=#ff0000]ord[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc][[/color]3[color=#0000cc]][/color][color=#0000cc])[/color] [color=#0000cc]&[/color] 0x3f[color=#0000cc];[/color]
      [color=#0000ff]return[/color] [color=#0000ff]$[/color][color=#008080]n[/color][color=#0000cc];[/color]
  [color=#0000cc]}[/color]
[color=#0000cc]}[/color]
[color=#0000cc]?[/color][color=#0000cc]>[/color]
[/color]

下面的例子是利用php将"全"这中编码转换为gb2312.
[color=#000000][color=#0000cc]<[/color][color=#0000cc]?[/color][color=#0000ff]php[/color]
[color=#0000ff]$[/color][color=#008080]str[/color] [color=#0000cc]=[/color] [color=#ff00ff]"TTL全天候自动聚焦"[/color][color=#0000cc];[/color]
[color=#0000ff]$[/color][color=#008080]str[/color] [color=#0000cc]=[/color] [color=#ff0000]preg_replace[/color][color=#0000cc]([/color][color=#ff00ff]"|&#([0-9]{1,5});|"[/color][color=#0000cc],[/color] [color=#ff00ff]"\".u2utf82gb(\\1).\""[/color][color=#0000cc],[/color] [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]$[/color][color=#008080]str[/color] [color=#0000cc]=[/color] [color=#ff00ff]"\$str=\"$str\";"[/color][color=#0000cc];[/color]

[color=#ff0000]eval[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]echo[/color] [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc];[/color]

[color=#0000ff]function[/color] u2utf82gb[color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc])[/color][color=#0000cc]{[/color]
    [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc]=[/color][color=#ff00ff]""[/color][color=#0000cc];[/color]
    [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]<[/color] 0x80[color=#0000cc])[/color] [color=#0000cc]{[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc];[/color]
    [color=#0000cc]}[/color] [color=#0000ff]else[/color] [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]<[/color] 0x800[color=#0000cc])[/color] [color=#0000cc]{[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0xC0 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]6[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
    [color=#0000cc]}[/color] [color=#0000ff]else[/color] [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]<[/color] 0x10000[color=#0000cc])[/color] [color=#0000cc]{[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0xE0 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]12[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]6 [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
    [color=#0000cc]}[/color] [color=#0000ff]else[/color] [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]<[/color] 0x200000[color=#0000cc])[/color] [color=#0000cc]{[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0xF0 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]18[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]12 [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]6 [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
    [color=#0000cc]}[/color]
    [color=#0000ff]return[/color] [color=#ff0000]iconv[/color][color=#0000cc]([/color][color=#ff00ff]'UTF-8'[/color][color=#0000cc],[/color] [color=#ff00ff]'GB2312'[/color][color=#0000cc],[/color] [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000cc]?[/color][color=#0000cc]>[/color]
[/color]

或者是

function unescape($str) {
  $str = rawurldecode($str);
  preg_match_all("/(?:%u.{4})|&#x.{4};|&#\d+;|.+/U",$str,$r);
  $ar = $r[0];
print_r($ar);
  foreach($ar as $k=>$v) {
    if(substr($v,0,2) == "%u")
      $ar[$k] = iconv("UCS-2","GB2312",pack("H4",substr($v,-4)));
    elseif(substr($v,0,3) == "&#x")
      $ar[$k] = iconv("UCS-2","GB2312",pack("H4",substr($v,3,-1)));
    elseif(substr($v,0,2) == "&#") {
echo substr($v,2,-1)."<br>";
      $ar[$k] = iconv("UCS-2","GB2312",pack("n",substr($v,2,-1)));
    }
  }
  return join("",$ar);
}

$str = "TTL全天候自动聚焦";
echo unescape($str); //out TTL全天候自动聚焦



利用javascript来转换
[color=#000000][color=#0000cc]<[/color][color=#0000ff]style[/color][color=#0000cc]>[/color]
[color=#0000ff]BODY[/color] [color=#0000cc]{[/color]
[color=#0000ff]FONT[/color][color=#0000cc]-[/color][color=#ff0000]SIZE[/color][color=#0000cc]:[/color] 9pt[color=#0000cc];[/color] PADDING[color=#0000cc]-[/color]RIGHT[color=#0000cc]:[/color] 0px[color=#0000cc];[/color] PADDING[color=#0000cc]-[/color]LEFT[color=#0000cc]:[/color] 0px[color=#0000cc];[/color] PADDING[color=#0000cc]-[/color]BOTTOM[color=#0000cc]:[/color] 0px[color=#0000cc];[/color] PADDING[color=#0000cc]-[/color]TOP[color=#0000cc]:[/color] 0px[color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]input[/color] [color=#0000cc]{[/color]
[color=#0000ff]FONT[/color][color=#0000cc]-[/color][color=#ff0000]SIZE[/color][color=#0000cc]:[/color] 9pt[color=#0000cc];[/color] [color=#ff0000]height[/color][color=#0000cc]:[/color] 13pt[color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000cc]<[/color][color=#0000cc]/[/color][color=#0000ff]style[/color][color=#0000cc]>[/color]

[color=#0000cc]<[/color][color=#0000ff]script[/color] [color=#ff0000]language[/color][color=#0000cc]=[/color][color=#ff00ff]"JavaScript1.2"[/color][color=#0000cc]>[/color]
[color=#0000cc]/[/color][color=#0000cc]*[/color]
This following [color=#0000ff]code[/color] are designed and writen by Windy_sk [color=#0000cc]<[/color][color=#0000cc][[/color]email[color=#0000cc]][/color]seasonx[color=#0000cc]@[/color]163[color=#0000cc].[/color]net[color=#0000cc][[/color][color=#0000cc]/[/color]email[color=#0000cc]][/color][color=#0000cc]>[/color]
You can use it freely[color=#0000cc],[/color] but [color=#0000ff]u[/color] must held all the copyright
[color=#0000cc]*[/color][color=#0000cc]/[/color]

function Str2Unicode[color=#0000cc]([/color]str[color=#0000cc])[/color][color=#0000cc]{[/color]
[color=#0000ff]var[/color] arr [color=#0000cc]=[/color] new Array[color=#0000cc]([/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]for[/color][color=#0000cc]([/color][color=#0000ff]var[/color] [color=#0000ff]i[/color][color=#0000cc]=[/color]0[color=#0000cc];[/color][color=#0000ff]i[/color][color=#0000cc]<[/color]str[color=#0000cc].[/color]length[color=#0000cc];[/color][color=#0000ff]i[/color][color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc])[/color][color=#0000cc]{[/color]
  arr[color=#0000cc][[/color][color=#0000ff]i[/color][color=#0000cc]][/color][color=#0000cc]=[/color][color=#ff00ff]"&#"[/color] [color=#0000cc]+[/color] str[color=#0000cc].[/color]charCodeAt[color=#0000cc]([/color][color=#0000ff]i[/color][color=#0000cc])[/color] [color=#0000cc]+[/color] [color=#ff00ff]";"[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
return[color=#0000cc]([/color]arr[color=#0000cc].[/color]toString[color=#0000cc]([/color][color=#0000cc])[/color][color=#0000cc].[/color]replace[color=#0000cc]([/color][color=#0000cc]/[/color][color=#0000cc],[/color][color=#0000cc]/[/color]g[color=#0000cc],[/color][color=#ff00ff]""[/color][color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]

function Unicode2oStr[color=#0000cc]([/color]str[color=#0000cc])[/color][color=#0000cc]{[/color]
[color=#0000ff]var[/color] re[color=#0000cc]=[/color][color=#0000cc]/[/color][color=#0000cc]&[/color][color=#0000cc]#[/color][color=#0000cc][[/color][color=#0000cc]\[/color]da[color=#0000cc]-[/color]fA[color=#0000cc]-[/color]F[color=#0000cc]][/color][color=#0000cc]{[/color]1[color=#0000cc],[/color]5[color=#0000cc]}[/color][color=#0000cc];[/color][color=#0000cc]/[/color]ig[color=#0000cc];[/color]
[color=#0000ff]var[/color] arr[color=#0000cc]=[/color]str[color=#0000cc].[/color]match[color=#0000cc]([/color]re[color=#0000cc])[/color][color=#0000cc];[/color]
if[color=#0000cc]([/color]arr[color=#0000cc]=[/color][color=#0000cc]=[/color]null[color=#0000cc])[/color]return[color=#0000cc]([/color][color=#ff00ff]""[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#ff0000]for[/color][color=#0000cc]([/color][color=#0000ff]var[/color] [color=#0000ff]i[/color][color=#0000cc]=[/color]0[color=#0000cc];[/color][color=#0000ff]i[/color][color=#0000cc]<[/color]arr[color=#0000cc].[/color]length[color=#0000cc];[/color][color=#0000ff]i[/color][color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc])[/color][color=#0000cc]{[/color]
  arr[color=#0000cc][[/color][color=#0000ff]i[/color][color=#0000cc]][/color][color=#0000cc]=[/color]String[color=#0000cc].[/color]fromCharCode[color=#0000cc]([/color]arr[color=#0000cc][[/color][color=#0000ff]i[/color][color=#0000cc]][/color][color=#0000cc].[/color]replace[color=#0000cc]([/color][color=#0000cc]/[/color][color=#0000cc][[/color][color=#0000cc]&[/color][color=#0000cc]#[/color][color=#0000cc];[/color][color=#0000cc]][/color][color=#0000cc]/[/color]g[color=#0000cc],[/color][color=#ff00ff]""[/color][color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
return[color=#0000cc]([/color]arr[color=#0000cc].[/color]toString[color=#0000cc]([/color][color=#0000cc])[/color][color=#0000cc].[/color]replace[color=#0000cc]([/color][color=#0000cc]/[/color][color=#0000cc],[/color][color=#0000cc]/[/color]g[color=#0000cc],[/color][color=#ff00ff]""[/color][color=#0000cc])[/color][color=#0000cc])[/color]
[color=#0000cc]}[/color]

function modi_str[color=#0000cc]([/color][color=#0000cc])[/color][color=#0000cc]{[/color]
if[color=#0000cc]([/color]document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color][color=#ff0000]method[/color][color=#0000cc].[/color][color=#ff0000]checked[/color][color=#0000cc])[/color][color=#0000cc]{[/color]
  if[color=#0000cc]([/color]document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color]decode[color=#0000cc].[/color][color=#ff00ff]value!=""[/color][color=#0000cc])[/color][color=#0000cc]{[/color]
   document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color]encode[color=#0000cc].[/color][color=#ff0000]value[/color] [color=#0000cc]=[/color] Str2Unicode[color=#0000cc]([/color]document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color]decode[color=#0000cc].[/color][color=#ff0000]value[/color][color=#0000cc])[/color][color=#0000cc];[/color]
  [color=#0000cc]}[/color]else[color=#0000cc]{[/color]
   document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color]decode[color=#0000cc].[/color][color=#ff0000]value[/color] [color=#0000cc]=[/color] Unicode2oStr[color=#0000cc]([/color]document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color]encode[color=#0000cc].[/color][color=#ff0000]value[/color][color=#0000cc])[/color][color=#0000cc];[/color]
  [color=#0000cc]}[/color]
[color=#0000cc]}[/color]else[color=#0000cc]{[/color]
  if[color=#0000cc]([/color]document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color]encode[color=#0000cc].[/color][color=#ff00ff]value!=""[/color][color=#0000cc])[/color][color=#0000cc]{[/color]
   document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color]decode[color=#0000cc].[/color][color=#ff0000]value[/color] [color=#0000cc]=[/color] Unicode2oStr[color=#0000cc]([/color]document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color]encode[color=#0000cc].[/color][color=#ff0000]value[/color][color=#0000cc])[/color][color=#0000cc];[/color]
  [color=#0000cc]}[/color]else[color=#0000cc]{[/color]
   document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color]encode[color=#0000cc].[/color][color=#ff0000]value[/color] [color=#0000cc]=[/color] Str2Unicode[color=#0000cc]([/color]document[color=#0000cc].[/color]all[color=#0000cc].[/color][color=#ff0000]text[/color][color=#0000cc].[/color]decode[color=#0000cc].[/color][color=#ff0000]value[/color][color=#0000cc])[/color][color=#0000cc];[/color]
  [color=#0000cc]}[/color]
[color=#0000cc]}[/color]
[color=#0000cc]}[/color]
[color=#0000cc]<[/color][color=#0000cc]/[/color][color=#0000ff]script[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]title[/color][color=#0000cc]>[/color]Unicode[color=#0000cc]<[/color][color=#0000cc]/[/color][color=#0000ff]title[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]form[/color] [color=#ff0000]name[/color][color=#0000cc]=[/color][color=#ff0000]text[/color][color=#0000cc]>[/color]
文本原型:[color=#0000cc]<[/color][color=#0000ff]br[/color][color=#0000cc]>[/color]
  [color=#0000cc]<[/color][color=#0000ff]textarea[/color] [color=#ff0000]name[/color][color=#0000cc]=[/color][color=#ff00ff]"decode"[/color] [color=#ff0000]cols[/color][color=#0000cc]=[/color][color=#ff00ff]"100"[/color] [color=#ff0000]rows[/color][color=#0000cc]=[/color][color=#ff00ff]"10"[/color][color=#0000cc]>[/color][color=#0000cc]<[/color][color=#0000cc]/[/color][color=#0000ff]textarea[/color][color=#0000cc]>[/color]
  [color=#0000cc]<[/color][color=#0000ff]br[/color][color=#0000cc]>[/color]
转换代码:[color=#0000cc]<[/color][color=#0000ff]br[/color][color=#0000cc]>[/color]
  [color=#0000cc]<[/color][color=#0000ff]textarea[/color] [color=#ff0000]name[/color][color=#0000cc]=[/color][color=#ff00ff]"encode"[/color] [color=#ff0000]cols[/color][color=#0000cc]=[/color][color=#ff00ff]"100"[/color] [color=#ff0000]rows[/color][color=#0000cc]=[/color][color=#ff00ff]"10"[/color][color=#0000cc]>[/color][color=#0000cc]<[/color][color=#0000cc]/[/color][color=#0000ff]textarea[/color][color=#0000cc]>[/color]
  [color=#0000cc]<[/color][color=#0000ff]br[/color][color=#0000cc]>[/color]
  [color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#ff00ff]"checkbox"[/color] [color=#ff0000]name[/color][color=#0000cc]=[/color][color=#ff00ff]"method"[/color] [color=#ff0000]checked[/color][color=#0000cc]>[/color] 正向转换
  [color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#0000ff]button[/color] [color=#ff0000]onclick[/color][color=#0000cc]=[/color][color=#ff00ff]"modi_str()"[/color] [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]" 确 定 "[/color][color=#0000cc]>[/color]
  [color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color]reset [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]" 清 空 "[/color][color=#0000cc]>[/color]
  [color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#0000ff]button[/color] [color=#ff0000]onclick[/color][color=#0000cc]=[/color][color=#ff00ff]"document.all.text.method.checked?document.all.text.encode.select():document.all.text.decode.select()"[/color] [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]" 全 选 "[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000cc]/[/color][color=#0000ff]form[/color][color=#0000cc]>[/color]

[/color]

下面是一个显示所有全角半角的字体的查看例子

[color=#000000][color=#0000cc]<[/color][color=#0000ff]style[/color][color=#0000cc]>[/color]
[color=#0000ff]BODY[/color] [color=#0000cc]{[/color]
[color=#0000ff]FONT[/color][color=#0000cc]-[/color][color=#ff0000]SIZE[/color][color=#0000cc]:[/color] 9pt[color=#0000cc];[/color] PADDING[color=#0000cc]-[/color]RIGHT[color=#0000cc]:[/color] 0px[color=#0000cc];[/color] PADDING[color=#0000cc]-[/color]LEFT[color=#0000cc]:[/color] 0px[color=#0000cc];[/color] PADDING[color=#0000cc]-[/color]BOTTOM[color=#0000cc]:[/color] 0px[color=#0000cc];[/color] PADDING[color=#0000cc]-[/color]TOP[color=#0000cc]:[/color] 0px[color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000ff]input[/color] [color=#0000cc]{[/color]
[color=#0000ff]FONT[/color][color=#0000cc]-[/color][color=#ff0000]SIZE[/color][color=#0000cc]:[/color] 9pt[color=#0000cc];[/color] [color=#ff0000]height[/color][color=#0000cc]:[/color] 13pt[color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000cc]<[/color][color=#0000cc]/[/color][color=#0000ff]style[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]script[/color][color=#0000cc]>[/color]
function showUni[color=#0000cc]([/color]min[color=#0000cc],[/color]max[color=#0000cc])[/color][color=#0000cc]{[/color]
show[color=#0000cc].[/color]document[color=#0000cc].[/color]open[color=#0000cc]([/color][color=#0000cc])[/color][color=#0000cc];[/color]
show[color=#0000cc].[/color]document[color=#0000cc].[/color]writeln[color=#0000cc]([/color][color=#ff00ff]"<style>body{font-size:9pt;word-break:break-all;}</style>"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
show[color=#0000cc].[/color]document[color=#0000cc].[/color]writeln[color=#0000cc]([/color]min [color=#0000cc]+[/color] [color=#ff00ff]" - "[/color] [color=#0000cc]+[/color] max [color=#0000cc]+[/color] [color=#ff00ff]"<br><br>"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000ff]var[/color] [color=#0000ff]i[/color][color=#0000cc]=[/color]0[color=#0000cc];[/color]
[color=#ff0000]for[/color][color=#0000cc]([/color][color=#0000ff]i[/color][color=#0000cc]=[/color]min[color=#0000cc];[/color][color=#0000ff]i[/color][color=#0000cc]<[/color][color=#0000cc]=[/color]max[color=#0000cc];[/color][color=#0000ff]i[/color][color=#0000cc]+[/color][color=#0000cc]+[/color][color=#0000cc])[/color][color=#0000cc]{[/color]
  show[color=#0000cc].[/color]document[color=#0000cc].[/color]write[color=#0000cc]([/color][color=#ff00ff]"&#"[/color] [color=#0000cc]+[/color] [color=#0000ff]i[/color] [color=#0000cc]+[/color] [color=#ff00ff]";"[/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
show[color=#0000cc].[/color]document[color=#0000cc].[/color]close[color=#0000cc]([/color][color=#0000cc])[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]
[color=#0000cc]<[/color][color=#0000cc]/[/color][color=#0000ff]script[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#0000ff]button[/color] [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]"半角"[/color]  [color=#ff0000]onclick[/color][color=#0000cc]=[/color]showUni[color=#0000cc]([/color]32[color=#0000cc],[/color]126[color=#0000cc])[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#0000ff]button[/color] [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]"全角"[/color]  [color=#ff0000]onclick[/color][color=#0000cc]=[/color]showUni[color=#0000cc]([/color]65281[color=#0000cc],[/color]65374[color=#0000cc])[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#0000ff]button[/color] [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]"中文1"[/color] [color=#ff0000]onclick[/color][color=#0000cc]=[/color]showUni[color=#0000cc]([/color]19968[color=#0000cc],[/color]40869[color=#0000cc])[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#0000ff]button[/color] [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]"中文2"[/color] [color=#ff0000]onclick[/color][color=#0000cc]=[/color]showUni[color=#0000cc]([/color]63744[color=#0000cc],[/color]64045[color=#0000cc])[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#0000ff]button[/color] [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]"日文平"[/color]  [color=#ff0000]onclick[/color][color=#0000cc]=[/color]showUni[color=#0000cc]([/color]12353[color=#0000cc],[/color]12435[color=#0000cc])[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#0000ff]button[/color] [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]"日文片"[/color]  [color=#ff0000]onclick[/color][color=#0000cc]=[/color]showUni[color=#0000cc]([/color]12449[color=#0000cc],[/color]12534[color=#0000cc])[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#0000ff]button[/color] [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]"韩文"[/color]  [color=#ff0000]onclick[/color][color=#0000cc]=[/color]showUni[color=#0000cc]([/color]44032[color=#0000cc],[/color]55203[color=#0000cc])[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]br[/color][color=#0000cc]>[/color]自定义:[color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]name[/color][color=#0000cc]=[/color]min[color=#0000cc]>[/color] [color=#0000cc]-[/color] [color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]name[/color][color=#0000cc]=[/color]max[color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]input[/color] [color=#ff0000]type[/color][color=#0000cc]=[/color][color=#0000ff]button[/color] [color=#ff0000]value[/color][color=#0000cc]=[/color][color=#ff00ff]"察看"[/color] [color=#ff0000]onclick[/color][color=#0000cc]=[/color]showUni[color=#0000cc]([/color]parseInt[color=#0000cc]([/color]document[color=#0000cc].[/color]all[color=#0000cc].[/color]min[color=#0000cc].[/color][color=#ff0000]value[/color][color=#0000cc])[/color][color=#0000cc],[/color]parseInt[color=#0000cc]([/color]document[color=#0000cc].[/color]all[color=#0000cc].[/color]max[color=#0000cc].[/color][color=#ff0000]value[/color][color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]br[/color][color=#0000cc]>[/color]
[color=#0000cc]<[/color][color=#0000ff]iframe[/color] [color=#ff0000]src[/color][color=#0000cc]=[/color][color=#ff00ff]"about:blank"[/color] [color=#ff0000]id[/color][color=#0000cc]=[/color]show [color=#ff0000]width[/color][color=#0000cc]=[/color]100[color=#0000cc]%[/color] [color=#ff0000]height[/color][color=#0000cc]=[/color]70[color=#0000cc]%[/color] scroll[color=#0000cc]=[/color]no[color=#0000cc]>[/color][color=#0000cc]<[/color][color=#0000cc]/[/color][color=#0000ff]iframe[/color][color=#0000cc]>[/color]
[/color]

下面是一个查表(gb2312),转换gb2312到utf8的例子, 现在有iconv函数,这个已经没有太大的意义了,
[color=#000000][color=#0000cc]<[/color][color=#0000cc]?[/color]
[color=#0000ff]function[/color] gb2utf8[color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc])[/color][color=#0000cc]{[/color]
    [color=#0000ff]if[/color][color=#0000cc]([/color][color=#0000cc]![/color][color=#ff0000]trim[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc])[/color][color=#0000cc])[/color]  [color=#0000ff]return[/color] [color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc];[/color]
    [color=#0000ff]$[/color][color=#008080]filename[/color][color=#0000cc]=[/color][color=#ff00ff]"gb2312.txt"[/color][color=#0000cc];[/color]
    [color=#0000ff]$[/color][color=#008080]tmp[/color][color=#0000cc]=[/color][color=#ff0000]file[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]filename[/color][color=#0000cc])[/color][color=#0000cc];[/color]
    [color=#0000ff]$[/color][color=#008080]codetable[/color][color=#0000cc]=[/color][color=#ff0000]array[/color][color=#0000cc]([/color][color=#0000cc])[/color][color=#0000cc];[/color]
    [color=#0000ff]while[/color][color=#0000cc]([/color][color=#ff0000]list[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]key[/color][color=#0000cc],[/color][color=#0000ff]$[/color][color=#008080]value[/color][color=#0000cc])[/color][color=#0000cc]=[/color][color=#ff0000]each[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]tmp[/color][color=#0000cc])[/color][color=#0000cc])[/color]
          [color=#0000ff]$[/color][color=#008080]codetable[/color][color=#0000cc][[/color][color=#ff0000]hexdec[/color][color=#0000cc]([/color][color=#ff0000]substr[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]value[/color][color=#0000cc],[/color]0[color=#0000cc],[/color]6[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc]][/color][color=#0000cc]=[/color][color=#ff0000]substr[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]value[/color][color=#0000cc],[/color]7[color=#0000cc],[/color]6[color=#0000cc])[/color][color=#0000cc];[/color]

    [color=#0000ff]$[/color][color=#008080]utf8[/color][color=#0000cc]=[/color][color=#ff00ff]""[/color][color=#0000cc];[/color]
    [color=#0000ff]while[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc])[/color] [color=#0000cc]{[/color]
        [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#ff0000]ord[/color][color=#0000cc]([/color][color=#ff0000]substr[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc],[/color]0[color=#0000cc],[/color]1[color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc]>[/color]127[color=#0000cc])[/color] [color=#0000cc]{[/color]
          [color=#0000ff]$[/color][color=#008080]this[/color][color=#0000cc]=[/color][color=#ff0000]substr[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc],[/color]0[color=#0000cc],[/color]2[color=#0000cc])[/color][color=#0000cc];[/color]
          [color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc]=[/color][color=#ff0000]substr[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc],[/color]2[color=#0000cc],[/color][color=#ff0000]strlen[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc])[/color][color=#0000cc]-[/color]2[color=#0000cc])[/color][color=#0000cc];[/color]
          [color=#0000ff]$[/color][color=#008080]utf8[/color][color=#0000cc].[/color][color=#0000cc]=[/color]u2utf8[color=#0000cc]([/color][color=#ff0000]hexdec[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]codetable[/color][color=#0000cc][[/color][color=#ff0000]hexdec[/color][color=#0000cc]([/color][color=#ff0000]bin2hex[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]this[/color][color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc]-[/color]0x8080[color=#0000cc]][/color][color=#0000cc])[/color][color=#0000cc])[/color][color=#0000cc];[/color]
        [color=#0000cc]}[/color][color=#0000ff]else[/color][color=#0000cc]{[/color]
            [color=#0000ff]$[/color][color=#008080]this[/color][color=#0000cc]=[/color][color=#ff0000]substr[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc],[/color]0[color=#0000cc],[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
            [color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc]=[/color][color=#ff0000]substr[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc],[/color]1[color=#0000cc],[/color][color=#ff0000]strlen[/color][color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]gb[/color][color=#0000cc])[/color][color=#0000cc]-[/color]1[color=#0000cc])[/color][color=#0000cc];[/color]
            [color=#0000ff]$[/color][color=#008080]utf8[/color][color=#0000cc].[/color][color=#0000cc]=[/color]u2utf8[color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]this[/color][color=#0000cc])[/color][color=#0000cc];[/color]
        [color=#0000cc]}[/color]
    [color=#0000cc]}[/color]
    [color=#0000ff]return[/color] [color=#0000ff]$[/color][color=#008080]utf8[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]

[color=#0000ff]function[/color] u2utf8[color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc])[/color][color=#0000cc]{[/color]
    [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc]=[/color][color=#ff00ff]""[/color][color=#0000cc];[/color]
    [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]<[/color] 0x80[color=#0000cc])[/color] [color=#0000cc]{[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc];[/color]
    [color=#0000cc]}[/color] [color=#0000ff]else[/color] [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]<[/color] 0x800[color=#0000cc])[/color] [color=#0000cc]{[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0xC0 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]6[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
    [color=#0000cc]}[/color] [color=#0000ff]else[/color] [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]<[/color] 0x10000[color=#0000cc])[/color] [color=#0000cc]{[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0xE0 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]12[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]6 [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
    [color=#0000cc]}[/color] [color=#0000ff]else[/color] [color=#0000ff]if[/color] [color=#0000cc]([/color][color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]<[/color] 0x200000[color=#0000cc])[/color] [color=#0000cc]{[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0xF0 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]18[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]12 [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color][color=#0000cc]>[/color][color=#0000cc]>[/color]6 [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
         [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc].[/color][color=#0000cc]=[/color][color=#ff0000]chr[/color][color=#0000cc]([/color]0x80 [color=#0000cc]|[/color] [color=#0000ff]$[/color][color=#008080]c[/color] [color=#0000cc]&[/color] 0x3F[color=#0000cc])[/color][color=#0000cc];[/color]
    [color=#0000cc]}[/color]
    [color=#0000ff]return[/color] [color=#0000ff]$[/color][color=#008080]str[/color][color=#0000cc];[/color]
[color=#0000cc]}[/color]

[color=#0000cc]?[/color][color=#0000cc]>[/color][/color]

Nothing 2007-7-14 10:21

iconv函数就全搞定了,还用费那么多事吗?
页: [1]
查看完整版本: 用php实现gb2312和unicode间的编码转换