My own special recipe is to not worry about it! :)

If you have a green-fields project with no existing database, all you do is:

- Make sure the database is UTF-8
- Set the encoding to UTF-8 for any page returned to the client. (if you have a form on a page and the page was set to UTF-8, the data is submitted as UTF-8 by the browser, so no conversion needed by you) - Make sure any files (ADP, resource files with messages, etc) are saved as UTF-8 if they contain such data.

It then basically takes care of itself.

The only issues I ever faced was (CSV) file uploads, where the data needed to be extracted and put into the database. This could contain any encoding without me knowing. In practice it only ever contained stupid Windows encoding, so I assumed that to be the case and used Tcl's convert functions.

Bas.

On 03/04/2008, at 9:25 AM, Tom Jackson wrote:

Just to back up what Bas said, AOLserver has been, and probably still is,
light years ahead of most systems when handling encoding issues.

Tcl is essentially UTF-8, which is multi-byte. But there are so many issues involved, you have to become something of an expert. The good news is that
AOLserver/Tcl has the tools to handle the issues.

tom jackson


On Wednesday 02 April 2008 15:38, Bas Scheffers wrote:
Some questions to help us, and maybe give you some hints as to what
might be wrong.

How did you determine the fact that the value isn't a correct Tcl
string?

What encoding is the database in? (UTF-8?) Are you 100% sure the data
in the database is actually correct?

I wouldn't think you would need to convert anything. Tcl uses UTF-8
internally. A string from the database should be nothing more than an
array of bytes and when a Tcl string is created, it is assumed these
bytes are UTF-8.

Did you specify the correct encoding in either the server headers
(preferred) or html tags? Unless you do that, the browser won't know
what character set it should use.

Regards,
Bas.

On 03/04/2008, at 4:52 AM, Rajesh nair wrote:
Hi all,

We have an existing Tcl service which provides the data from mysql
to clients as an HTML table.
We have some records in mysql with multibye characters which are not
being rendered correctly.

Simple ns_db getrow does not return me the correctly encoded data
form database.
I have the sample code snippet to replicate this

      set db [ns_db gethandle]

      set sql1 "use mydb";
      ns_db exec $db $sql1;
            set row [ns_db select $db "select title from channel"]
      set numcols [ns_set size $row]
          while {[ns_db getrow $db $row]} {
         for {set i 0} {$i < $numcols} {incr i} {
            ns_puts " :[ns_set value $row $i]"
        }
        ns_puts "<br>"        }

I understand that I need to specify the encoding to get the correct
tcl strings in ns_set but cannot find the way to do so. Any pointers?

Thanks in advance--
-- Rajesh Nair


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to
<[EMAIL PROTECTED]

with the

body of "SIGNOFF AOLSERVER" in the email message. You can leave the
Subject: field of your email blank.

--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to
<[EMAIL PROTECTED]> with the body of "SIGNOFF AOLSERVER" in the
email message. You can leave the Subject: field of your email blank.


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED] > with the body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: field of your email blank.


--
AOLserver - http://www.aolserver.com/

To Remove yourself from this list, simply send an email to <[EMAIL PROTECTED]> 
with the
body of "SIGNOFF AOLSERVER" in the email message. You can leave the Subject: 
field of your email blank.

Reply via email to