0

アラビア語の UNICODE 基本ゾーンの一部のテキストを UNICODE 拡散エリア コー​​ドに変換するという問題に遭遇しましたが、成功しませんでした。

<?
header("content-type: text/html; charset=utf-8");
    mb_http_output( "UTF-8" );
function Un2k($Un){
     $Uk[0] ="چېتيڭپسىقكلشغبنمفگخجروۈزۋداەژۆۇﻻﺋھ";
        $Uk[1] = "ﭺﯥﺕﻱﯓﭖﺱﻯﻕﻙﻝﺵﻍﺏﻥﻡﻑﮒﺥﺝﺭﻭﯛﺯﯞﺩﺍﻩﮊﯙﯗﻻ∥∥";
        $Uk[2] = "ﭼﯦﺗﻳﯕﭘﺳﯨﻗﻛﻟﺷﻏﺑﻧﻣﻓﮔﺧﺟ∥∥∥∥∥∥∥∥∥∥∥∥ﺋﮬ";
        $Uk[3] = "ﭻﯥﺖﻲﯔﭗﺲﻰﻖﻚﻞﺶﻎﺐﻦﻢﻒﮓﺦﺞﺮﻮﯜﺰﯟﺪﺎﻪﮋﯚﯘﻼ∥∥";
        $Uk[4] = "ﭽﯧﺘﻴﯖﭙﺴﯩﻘﻜﻠﺸﻐﺒﻨﻤﻔﮕﺨຠ∥∥∥∥∥∥∥∥∥∥∥∥ﺌﮭ";

        $Un2K1 = "";
        $i ;
        $ix ;
        $s ;
        $s_ ;
        $_s ;
        $L ;
        $_ix ;
        $ix_ ;
        $_TF ;
        $TF_ ;
        $L = mb_strlen($Un,"utf8");

        for ($i=1;$i<$L;$i++){
            $s = mb_substr($Un, $i, 1,"utf8");

            if($i!=$L){ $s_ = mb_substr($Un, $i + 1, 1,"utf8");}else{$s_="";}
            if($i>1){ $_s = mb_substr($Un, $i - 1, 1,"utf8");}else{$_s="";}
            $ix = mb_strpos($Uk[0], $s);
             if(empty($ix)){
                 //
               if($i!=$L){$ix_ = mb_strpos($Uk[0], $s_);}else{$ix_="";}
               if($i>1){$_ix = mb_strpos($Uk[0], $_s);}else{$_ix="";}
               //
                 if($_ix == 0 or mb_strpos("روۈزۋداەژۆۇ", $_s) != 0){
                      $_TF = false;
                 }elseif(mb_substr($Uk[2], $_ix, 1,"utf8") != "." or mb_substr($Uk[4], $_ix, 1,"utf8") != "."){
                     $_TF = true;
                 }
                 if($ix==0){
                    $TF_ = false;
                 }elseif(mb_substr($Uk[3], $ix_, 1,"utf8") != "." or mb_substr($Uk[4], $ix_, 1,"utf8") != "."){
                     $_TF = true;
                 }
                 if(mb_strpos("چېتيڭپسىقكلشغبنمفگخج", $s) != 0){
                     if($_TF == false and $TF_ == false){
                         $Un2K1 = $Un2K1.mb_substr($Uk[1], $ix, 1,"utf8");
                     }elseif($_TF == true and $TF_ == false){
                         $Un2K1 = $Un2K1.mb_substr($Uk[3], $ix, 1,"utf8");
                     }elseif($_TF == false and $TF_ == true){
                         $Un2K1 = $Un2K1.mb_substr($Uk[2], $ix, 1,"utf8");
                     }

                 }elseif(mb_strpos("روۈزۋداەژۆۇ", $s) != 0){
                     if($_TF == false){
                        $Un2K1 = $Un2K1.mb_substr($Uk[1], $ix, 1,"utf8");
                     }elseif($_TF == true){
                        $Un2K1 = $Un2K1.mb_substr($Uk[3], $ix, 1,"utf8");
                     }
                 }else{
                     if($TF_ == false){
                        $Un2K1 = $Un2K1.mb_substr($Uk[4], $ix, 1,"utf8");
                     }elseif($TF_ == true){
                        $Un2K1 = $Un2K1.mb_substr($Uk[2], $ix, 1,"utf8");
                     }
                 }

             }else{
                 $Un2K1 = $Un2K1.$s;
             }
        }
        $Un2K1 = str_ireplace("ﻟﺎ", "ﻻ",$Un2K1);
        $Un2K1 = str_ireplace("(", "<!>",$Un2K1);
        $Un2K1 = str_ireplace(")", "(",$Un2K1);
        $Un2K1 = str_ireplace("<!>", ")",$Un2K1);
        $Un2K1 = str_ireplace("«", "<!>",$Un2K1);
        $Un2K1 = str_ireplace("»", "«",$Un2K1);
        $Un2K1 = str_ireplace("<!>", "»",$Un2K1);
        $Un2K1 = str_ireplace("", "",$Un2K1);
        $Un2K1 = str_ireplace("", "",$Un2K1);
        //$Un2K1 = santatur2($Un2K1);

        return  $Un2K1;
}


function santatur2($str) {  
    $len = mb_strlen($str, 'UTF-8');  
    $string = '';  
    for ($i = $len - 1; $i >= 0; $i--) {  
       $string .= mb_substr($str, $i, 1, 'UTF-8');                                                           
    }  
    return $string;  
} 


















?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>

<body>

<?

echo(Un2k("شاكىر"));


?>

</body>

</html>
4

1 に答える 1

0

mb_convert_encoding()を使用しないのはなぜですか。あなたの場合、それは非常に役立つはずです。

EUC-JP を UTF-7 に変換する例を次に示します。

$str = mb_convert_encoding($str, "UTF-7", "EUC-JP");

サポートされているエンコーディングのリスト

于 2012-05-19T08:52:40.633 に答える