handling Japanese (UTF-8?) text with Rev, CGI, & MySQL
niconiko at gmail.com
Thu Feb 21 03:40:20 CST 2008
I have a Rev stack that connects to a MySQL database
by calling a Rev-cgi script. The stack is running locally,
while the cgi-script and the database are on my wehhost's
Everything works fine except for the displaying in a text-field
of the downloaded data. The English text arrives fine, but the
Japanese text appears as one question mark per character.
I'm including below what I think is the relecant information,
namely, the MySQL table structure, the Rev-CGI script,
and the stack-script.
Any ideas how to handle the Japanese text so that it'll appear
correctly? I've already tried a combination of collations (UTF-8,
and shift-jis), "Content-Type", "charset=", and Rev unicode
decoding/encoding/HTMLtext commands, but I can't seem to
hit upon the right mix.
-- THE MySQL TABLE --
The table's collation (character encoding?) is latin1_general_ci,
but the collation of the Japanese field is sjis_japanese_ci.
-- THE CGI SCRIPT
put "SELECT * FROM `table`" into sql
put revDataFromQuery(,,connid,sql) into vResults
put vResults & return & the seconds after buffer
put "Content-Type: text/plain" & cr
put "Content-Length:" && the length of buffer & cr & cr
-- THE STACK SCRIPT
put field "fURL" into tURL
get url tURL
put it into field "fResult"
More information about the use-livecode