[Cartoweb-users] Display data in Chinese

Oliver Christen oliver.christen at camptocamp.com
Tue Sep 23 05:31:09 EDT 2008


you mean on the map image generated by mapserver ?

mmm, if the string is encoded in utf8 or unicode it should be passed 
correctly from Cartoweb to mapserver, as long as the font you specified in 
the LABEL definition in the mapfile contains the corresponding characters.

be sure the ENCODING parameter is set correctly in the related outline layer 
in your mapfile, especially if you use another encoding.

the mapoverlay plugin (used internal by the outline plugin) do not support 
dynamic modification of the ENCODING value, so you must use the same 
encoding for all the text you input.
if thats a problem, you must modify a bit the mapoverlay plugin to implement 
the "encoding" parameter. let me know if you need more details about that.

regards
Oliver

>
> Thanks very much, I can now handle chinese characters in search and 
> tooltips
> plugins.
>
> However, for the outline plugin, how can I make it to display the labels 
> in
> chinese?
>
> Thanks.
>
> Regards,
> Jady
>
>
>
>
> Oliver Christen wrote:
>>
>> 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
>>>
>>
>> _______________________________________________
>> Cartoweb-users mailing list
>> Cartoweb-users at lists.maptools.org
>> http://lists.maptools.org/mailman/listinfo/cartoweb-users
>>
>>
>
> -- 
> View this message in context: 
> http://www.nabble.com/Display-data-in-Chinese-tp16547531p19620641.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