[Mapserver-users] about unicode to big5?

Mikeyahoo mike_5102 at yahoo.com.tw
Sun Jan 12 00:15:17 PST 2003


This is a multi-part message in MIME format.

------=_NextPart_000_000C_01C2BA55.CC071D40
Content-Type: text/plain;
	charset="big5"
Content-Transfer-Encoding: quoted-printable

Hello all,
I have PHP ver4.0.6 and MapServer version 3.5. and the dbms is =
postgresql7.1.3.I want to show the big5 on my map.My db had already =
converted the unicode to the big5,but the map on web still show the =
unicode.So I want to use php/mapscript to convert the word.following is =
the program that download on web:
<?php
   Function U2Utf8($c){
      If($c < 0x80) {
         $str.=3D$c;
      }ElseIf($c < 0x800) {
         $str.=3D(0xC0 | $c>>6);
         $str.=3D(0x80 | $c & 0x3F);
      }ElseIf($c < 0x10000) {
         $str.=3D(0xE0 | $c>>12);
         $str.=3D(0x80 | $c>>6 & 0x3F);
         $str.=3D(0x80 | $c & 0x3F);
      }ElseIf($c < 0x200000) {
         $str.=3D(0xF0 | $c>>18);
         $str.=3D(0x80 | $c>>12 & 0x3F);
         $str.=3D(0x80 | $c>>6 & 0x3F);
         $str.=3D(0x80 | $c & 0x3F);
      }
      Return $str;
   }

Function Big52Utf8($Big5){
   //Modify By MingSen Zhao

   If(!Trim($Big5)) Return $Big5;
   $tmp=3DFile("./BIG5.TXT");
   Foreach($tmp as $key =3D> $value)
      $codetable[Hexdec(Substr($value,0,6))]=3DSubstr($value,7,6);

   While($Big5){
      If(Ord(Substr($Big5,0,1))>127){

$utf8=3DU2Utf8(Hexdec($codetable[Hexdec(Bin2hex(Substr($Big5,0,2)))]));
         For($i=3D0;$i<Strlen($utf8);$i+=3D3)
            $ret.=3DChr(Substr($utf8,$i,3));
         $Big5=3DSubstr($Big5,2,Strlen($Big5));
      }Else{
         $ret.=3DSubstr($Big5,0,1);
         $Big5=3DSubstr($Big5,1,Strlen($Big5));
      }
   }
   Return $ret;
}

it need a file "big5.txt" that is a u8tob5 table.this program can be =
running correctly.but the word on map is still unreadable.It seems to =
transfer uncompletely.And the tansfer time is slowly.Are there any =
methods that can work like this and more efficiency?

thanks for your response!

------=_NextPart_000_000C_01C2BA55.CC071D40
Content-Type: text/html;
	charset="big5"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; charset=3Dbig5">
<META content=3D"MSHTML 5.50.4134.100" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DMingLiu size=3D2>Hello all,</FONT></DIV>
<DIV><FONT face=3D=B2=D3=A9=FA=C5=E9>I have PHP ver4.0.6 and =
MapServer version 3.5. and the=20
dbms is <FONT color=3D#ff0000>postgresql7.1.3</FONT>.I want to show the =
big5 on my=20
map.My db had already converted the unicode to the big5,but=20
the map on web still show the unicode.So I want to use =
php/mapscript=20
to convert the word.following is the program that download on=20
web:</FONT></DIV>
<DIV><FONT face=3DMingLiu size=3D2><?php</FONT></DIV>
<DIV><FONT face=3DMingLiu size=3D2>   Function=20
U2Utf8($c){<BR>      If($c < 0x80)=20
{<BR>        =20
$str.=3D$c;<BR>      }ElseIf($c < 0x800)=20
{<BR>         $str.=3D(0xC0 |=20
$c>>6);<BR>         =
$str.=3D(0x80 |=20
$c & 0x3F);<BR>      }ElseIf($c < =
0x10000)=20
{<BR>         $str.=3D(0xE0 |=20
$c>>12);<BR>         =
$str.=3D(0x80 |=20
$c>>6 & =
0x3F);<BR>        =20
$str.=3D(0x80 | $c & 0x3F);<BR>      =
}ElseIf($c <=20
0x200000) {<BR>         =
$str.=3D(0xF0 |=20
$c>>18);<BR>         =
$str.=3D(0x80 |=20
$c>>12 & =
0x3F);<BR>        =20
$str.=3D(0x80 | $c>>6 &=20
0x3F);<BR>         $str.=3D(0x80 =
| $c=20
& 0x3F);<BR>     =20
}<BR>      Return $str;<BR>   =
}</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DMingLiu size=3D2>Function =
Big52Utf8($Big5){<BR>  =20
//Modify By MingSen Zhao</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DMingLiu size=3D2>   If(!Trim($Big5)) Return=20
$Big5;<BR>   $tmp=3DFile("./BIG5.TXT");<BR>   =
Foreach($tmp as=20
$key =3D> $value)<BR>     =20
$codetable[Hexdec(Substr($value,0,6))]=3DSubstr($value,7,6);</FONT></DIV>=

<DIV> </DIV>
<DIV><FONT face=3DMingLiu size=3D2>  =20
While($Big5){<BR>     =20
If(Ord(Substr($Big5,0,1))>127){</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=3DMingLiu=20
size=3D2>$utf8=3DU2Utf8(Hexdec($codetable[Hexdec(Bin2hex(Substr($Big5,0,2=
)))]));<BR>        =20
For($i=3D0;$i<Strlen($utf8);$i+=3D3)<BR>     =
      =20
$ret.=3DChr(Substr($utf8,$i,3));<BR>      &=
nbsp; =20
$Big5=3DSubstr($Big5,2,Strlen($Big5));<BR>      =

}Else{<BR>        =20
$ret.=3DSubstr($Big5,0,1);<BR>       &=
nbsp;=20
$Big5=3DSubstr($Big5,1,Strlen($Big5));<BR>      =

}<BR>   }<BR>   Return $ret;<BR>}<BR></FONT></DIV>
<DIV><FONT face=3DMingLiu size=3D2>it need a file "big5.txt" that =
is a u8tob5=20
table.this program can be running correctly.but the word on map is=20
still unreadable.It seems to transfer uncompletely.And the =
tansfer=20
time is slowly.Are there any methods that can work like this =
and more=20
efficiency?</FONT></DIV>
<DIV><FONT face=3DMingLiu size=3D2></FONT> </DIV>
<DIV><FONT face=3DMingLiu size=3D2>thanks for your=20
response!</DIV></FONT></BODY></HTML>

------=_NextPart_000_000C_01C2BA55.CC071D40--

-----------------------------------------------------------------
< ¨C¤Ñ³£ Yahoo!©_¼¯ >  www.yahoo.com.tw




More information about the MapServer-users mailing list