Forum Moderators: open

Message Too Old, No Replies

AJAX, IIS, UTF-8 Question

         

reybango

1:54 pm on May 12, 2006 (gmt 0)

10+ Year Member



Hi everyone. I'm doing my best to learn about Ajax and development of web apps using this architecture. I recently read this:

"Ajax uses UTF-8. Normal forms are sent using the encoding of the parent page. Thus a SJIS encoded page will default to sending form content encoded in SJIS. Ajax submitted forms on the other hand will be sent as UTF-8. If for some strange reason, UTF-8 is not the character set of choice for the server, this will require a solution such as the server recognizing and translating UTF-8 responses to a desired character encoding."

The line that immediately jumped out at me was this one:

"If for some strange reason, UTF-8 is not the character set of choice for the server, this will require a solution such as the server recognizing and translating UTF-8 responses to a desired character encoding."

Does this mean that IIS or Apache have to be explicitly setup to handle UTF-8? If so, how? I've never had to deal with since I've not worked on international sites so this is new to me.

I know I can set the charset to UTF-8 for a specific page via the following line:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

but again, I'm concerned about my web server not being configured to handle that.

Also, what about SQL Server? Does that have to be configured in some special way if I'm receiving AJAX data in UTF-8?

Rey...

jshanman

2:14 pm on May 12, 2006 (gmt 0)

10+ Year Member



Since you are probably using some server page (php,asp,jsp) to handle your AJAX requests, use that language to be aware of the encoding that is is processing, and convert to whatever coding is needed.

- JS

reybango

2:32 pm on May 12, 2006 (gmt 0)

10+ Year Member



So what you're saying is to take the UTF-8 encoded data and translate it via whatever dynamic page or component I'm using to whatever character set is appropriate?

Is there a more seamless way of doing this? Something that can be configured both in the application server and web server?

Rey...

jshanman

2:58 pm on May 12, 2006 (gmt 0)

10+ Year Member



You can set the default character set on the web-server, but if you write your applications to take care of it, then it will be easier to move these applications from one server to another...

Just create a global include file for your application that has a $outputCharSet variable. Otherwise if you move your application to a server that has a required charset, you'll have to re-program your applciation.

If you don't ever plan to move your application, then just set the default character set in your web server.

Apache: AddDefaultCharset utf-8
(http://httpd.apache.org/docs/2.0/mod/core.html)

- JS

reybango

3:07 pm on May 12, 2006 (gmt 0)

10+ Year Member



Gotcha. Thanks for the heads up on that.

Rey...