[Cartoweb-users] Display data in Chinese

Oliver Christen oliver.christen at camptocamp.com
Tue Apr 8 02:22:28 EDT 2008


Hi

Cartoweb can, by default, handle string encoded in UTF-8 and ISO-8859-1.
If the string are encoded using another encoding, for example BIG-5 ( used 
for chinese characters ), you will need to use php's Multibyte String 
Functions (http://ch2.php.net/mbstring) to convert the string in utf8 (or 
ISO-8859-1). See the mb_convert_encoding functions for more details 
(http://ch2.php.net/manual/en/function.mb-convert-encoding.php)

So, the first step would be to know which encoding is used for the chinese 
characters.
Once you know that, you can easily add some tableRules 
(http://www.cartoweb.org/doc_head/docbook/xhtml/dev.newplugin.html#dev.newplugin.special.tables 
and also see the tutorial, point 9 
http://www.cartoweb.org/cwiki/Foss4g06Workshops) to convert the encoding 
using the above-mentioned mb_convert_encoding function.
This will do for query result table.
For tooltips, you need to extend the toolTips plugin (as explained in the 
documentations) and apply the same encoding converstion on the result.

This is optional:
If you want to do it cleanly, you can create a new encoding/decoding class 
based on the existing encoding/decoding system. Simply look in 
/common/Encoding.php and you will see the existing "class EncoderUTF 
implements EncoderInterface" and "class EncoderISO implements 
EncoderInterface". If needed, simply make your own "class EncoderXYZ 
implements EncoderInterface" with the appropriate encode/decode function. 
Create a new plugin and put your code inside (I think that should be enough 
to be able to call the class). Define a new encoder id in your client.ini 
(for example EncoderClass.xyz = EncoderXYZ). Then you can simply use 
Encoder::decode($text, 'xyz') when you want to handle the chinese strings.

I dont know any details about php's Multibyte String Functions so you will 
have to ask php's support if you need more help with that part.

regards
Oliver

>
> Dear all,
>
> I am using Cartoweb3.4 and in my shapefiles, some of the attribute data 
> are
> in Chinese.  I would like to know how can I display these Chinese 
> characters
> in Cartoweb? Like in the query result table and tooltips, etc.  Right now
> strange symbols are displayed instead.
>
> Thank you very much in advance for any help.
>
> Best regards,
> Jady
> -- 
> View this message in context: 
> http://www.nabble.com/Display-data-in-Chinese-tp16547531p16547531.html
> Sent from the cartoweb-users mailing list archive at Nabble.com.
>
> _______________________________________________
> Cartoweb-users mailing list
> Cartoweb-users at lists.maptools.org
> http://lists.maptools.org/mailman/listinfo/cartoweb-users
> 



More information about the Cartoweb-users mailing list