Japanese text, cgi, sql (again)

Martin Baxter mb.userev at harbourhosting.co.uk
Thu Jun 4 03:16:32 EDT 2009


Nicolas Cueto wrote:
> Hello All,
> 
> On and off over the last three years, I've
> been trying to crack the problem of
> downloading Japanese text which is
> contained in a mysql database by
> a stack + rev.cgi combination.
> 
> It's that time of year again.
> 
> As with past attempts, my latest too
> works fine except for the same old
> problem --  Japanese text arrives
> in the stack garbled (English text
> is ok).
> 
> Having tried a variety of suggestions
> from this list and from Japanese-users
> of Rev (the database's and its fields'
> collations; Rev uniencode/unidecode/
> unicodetext commands; etc),   my
> latest thought is the problem may lie
> with this final part of my cgi script:
> 
> 
>   -- put "Content-Type: text/plain" & cr before buffer
>   -- put "Content-Type: text/html; charset = utf-8" & cr
>   put  "Content-Length:" && the length of buffer & cr & cr
>   put buffer
> 
> 
> As the commented-out lines show, I've tried
> different "Content-Type".  But not having a full
> understanding of how this or char-set work,
> they're just blind guesses.
> 
> Could the cgi-script's content-type / charset
> (or something else similar) be what's garbling
> the Japanese text?
> 
> Perhaps this year will be the lucky one.
> 
> Thanks.
> 
> --
> Nicolas Cueto

Hello Nicolas,

I'm no expert but, working with mySQL and websites, I have found that
the following MySQL command is needed to tell the database what kind of
data it is about to transmit (this assumes the data is actually utf-8 of
course)

SET NAMES 'utf8'

You would use revExecuteSQL with the connection id to isssue this after
making the connection and before trying to transmit the data. Every part
of the process has to be told what kind of data it is dealing with.

Martin Baxter

-- 
If you want to go fast, go alone; if you want to go far, go together
(African proverb)



More information about the use-livecode mailing list