PDA

View Full Version : encoding of pages loaded using dynamic ajax content script



billgates2000
12-07-2012, 02:12 PM
1) Script Title: Dynamic Ajax Content

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

3) Describe problem:

I've implemented this script in a calendar on my site, but I have problems with the encoding of the ajax-loaded pages (it's a specific greek encoding, not utf8). The strange thing is that it works great on Chrome, but IE and Firefox give this encoding issue.

Here's a link to the calendar:

http://1062943144.n82093.test.prositehosting.co.uk/calendar_front_end.asp

The first time the page is loaded, it doesn't use the ajax script so everything is fine in all browsers. But when the user clicks on the arrow buttons to switch between months, the page is re-loaded in the div using the ajax script and the greek month in the calendar doesn't show up correctly (in IE and Firefox).

Any idea how I can solve this issue?

Thanks.

traq
12-07-2012, 08:40 PM
The very first thing I would do is double-check that you can't use UTF8 for everything. AFAIK, UTF8 covers *everything*.

Failing that, you need to get everything (the page and the ajax'd text) using the same charset, and make sure your server is sending the correct HTTP header.

billgates2000
12-07-2012, 10:15 PM
ok, thanks a lot :)

djr33
12-07-2012, 10:32 PM
You can certainly use UTF8 for Greek. UTF16 may be required for particularly unusual characters, or some characters in Chinese, but not really for anything else.
Unless you're specifically in a situation where you know a lot about character encodings and are trying to do something unusual, you should be just fine with UTF8.

Note that you will need to convert your content. Sometimes this can be easy. Other times it might require manual cutting and pasting, or even some sort of more complicated conversion. Usually it works out fine, but sometimes it can be a little tricky.



AFAIK, UTF8 covers *everything*.I thought the same. But John corrected me-- UTF16 is required for some characters in Chinese and a few other things. It's also used for newer things that are added to unicode, but those are so rarely relevant it shouldn't matter. As a practical matter, it probably does cover everything unless you're dealing with Chinese (and other Asian languages with those characters).

bernie1227
12-08-2012, 12:17 AM
There has been a discussion on this elsewhere on the forums:
http://www.dynamicdrive.com/forums/showthread.php?69536-UTF-8-with-HTML5

molendijk
12-08-2012, 01:08 PM
If nothing helps and you don't know what to do anymore, you can always use this (http://mesdomaines.nu/eendracht/converters/convert_to_unicode.html).
It automatically converts any given alphabetic character to its HTML-entity counterpart. So, for instance, inputting Δ yields & # 9 1 6 ;.
I do this all the time for French. It's a habit you'll get rapidly accustomed to.
Arie.

Beverleyh
12-08-2012, 01:59 PM
One for the bookmarks! Thanks Arie