Skip to content Skip to sidebar Skip to footer

Xmlhttprequest Displays Eurosign As Questionmark

I use this script (from dynamicdrive) to dynamically fill div with id: var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no) v

Solution 1:

It seems like you have an encoding problem somewhere.

I highly suggest you to use UTF-8 everywhere as it is the established standard for the web. Check that the page doing the ajax call and the dynamically loaded page are encoded in UTF-8 and sent by the server with correct headers (the headers should contain something like Content-type: text/html; charset=UTF-8).

Also it is a best practice to replace exotic characters by their html firendly code in html pages to avoid such issues. Use € for €.

Solution 2:

This is my hypothesis (and I think it's been confirmed by your updates):

  • When you write the remote document you are loading, you just open your editor, hit the € symbol in your keyboard and save. Since you never picked any encoding, your editor used the ANSI code page. And here's the issue: the ANSI code page basically depends on where you live. In Western Europe, Win-1252 is a popular choice and encodes the euro symbol as 0x80.

  • When you write the target HTML doc where you want to insert it, you do exactly the same and get a Win-1252 document. However, the webserver doesn't know what the encoding is. Many times, it'll default to something like ISO-8859-1 and it happens that ISO-8859-1 does not even have an euro symbol!

  • JavaScript reads 0x80 and writes 0x80.

  • The browser finds 0x80 in an HTML document that's supposedly ISO-8859-1. In such encoding, the 0x80 is actually blank.

So you don't have to fix your JavaScript code (there's nothing fixable there, mainly because there's nothing wrong there). You need to find out what your site's encoding is and generate files that actually use such encoding (advanced editors will let you choose).

Post a Comment for "Xmlhttprequest Displays Eurosign As Questionmark"