handling Japanese (UTF-8?) text with Rev, CGI, & MySQL

Nicolas Cueto niconiko at gmail.com
Thu Feb 21 04:40:20 EST 2008


Hello List,

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 
server.

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.

Thank you.

--
Nicolas Cueto



-- 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

#!revolution
on startup
put revOpenDatabase("mysql","url.com","dbname","user","pwd")into  
connid
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
put buffer
end startup




-- THE STACK SCRIPT

on mouseUp
 put field "fURL" into tURL
 get url tURL
 put it into field "fResult"
end mouseUp






More information about the use-livecode mailing list