[Mapserver-users] about unicode to big5?

Mikeyahoo mike_5102 at yahoo.com.tw
Tue Jan 7 11:56:39 EST 2003


This is a multi-part message in MIME format.

------=_NextPart_000_000F_01C2B6B0.CD274F40
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_000F_01C2B6B0.CD274F40
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&nbsp;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&nbsp;had already converted the&nbsp;unicode to the big5,but=20
the&nbsp;map on web still show the unicode.So I want to use =
php/mapscript=20
to&nbsp;convert the word.following is the program that download on=20
web:</FONT></DIV>
<DIV><FONT face=3DMingLiu size=3D2>&lt;?php</FONT></DIV>
<DIV><FONT face=3DMingLiu size=3D2>&nbsp;&nbsp; Function=20
U2Utf8($c){<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; If($c &lt; 0x80)=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$str.=3D$c;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }ElseIf($c &lt; 0x800)=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $str.=3D(0xC0 |=20
$c&gt;&gt;6);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
$str.=3D(0x80 |=20
$c &amp; 0x3F);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }ElseIf($c &lt; =
0x10000)=20
{<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $str.=3D(0xE0 |=20
$c&gt;&gt;12);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
$str.=3D(0x80 |=20
$c&gt;&gt;6 &amp; =
0x3F);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$str.=3D(0x80 | $c &amp; 0x3F);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
}ElseIf($c &lt;=20
0x200000) {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
$str.=3D(0xF0 |=20
$c&gt;&gt;18);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
$str.=3D(0x80 |=20
$c&gt;&gt;12 &amp; =
0x3F);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$str.=3D(0x80 | $c&gt;&gt;6 &amp;=20
0x3F);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $str.=3D(0x80 =
| $c=20
&amp; 0x3F);<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
}<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Return $str;<BR>&nbsp;&nbsp; =
}</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DMingLiu size=3D2>Function =
Big52Utf8($Big5){<BR>&nbsp;&nbsp;=20
//Modify By MingSen Zhao</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DMingLiu size=3D2>&nbsp;&nbsp; If(!Trim($Big5)) Return=20
$Big5;<BR>&nbsp;&nbsp; $tmp=3DFile("./BIG5.TXT");<BR>&nbsp;&nbsp; =
Foreach($tmp as=20
$key =3D&gt; $value)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;=20
$codetable[Hexdec(Substr($value,0,6))]=3DSubstr($value,7,6);</FONT></DIV>=

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

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

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

------=_NextPart_000_000F_01C2B6B0.CD274F40--

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




More information about the mapserver-users mailing list