tags:

views:

21

answers:

3

Anyone have any ideas why a JQUERY LOAD Call which has "isn't" in the db is displaying as isnu2019t using JQUERY load?

A: 

Have you html encoded the return string from the server?

XIII
I'm using JQUERY load, which does that automatically right?
AnApprentice
A: 

Code point 0x2019 in Unicode is "Right Single Quotation Mark", which is the preferred Unicode character for apostrophe. My guess is that your DB is storing (and displaying in whatever you're using to look at it) unicode, and something in the path from your DB to jQuery (or jQuery itself) is turning that into u2019. Are you converting to latin-1 anywhere, or otherwise throwing away unicode data in some kind of string conversion?

Nick Bastin
The database is set to: Default Character Set: latin1, default collation: latin1_swedish_ci. This had to be the default settings as I've never changed it. Is this the issue?
AnApprentice
It's hard to say what the specific problem is without looking at the code through every step of the process, but your problem is definitely that something is sending you unicode, and you're not handling it, somewhere in your call chain.
Nick Bastin
A: 

This sounds like a character encoding problem. 0x2019 is the UTF-8 encoding for a "smart quote" (almost always something pasted from a Microsoft editor). Ensure that every step of the transaction understands what encoding is really in use.

  1. What is the character set used for that column in MySQL?
  2. What character set are you using in the SET NAMES query to MySQL at the beginning of the request? (Related thing to check: make sure you're even doing a SET NAMES)
  3. What character set are you declaring the response to be in when replying to the AJAX request?
VoteyDisciple
what do you recommend the MYSQL settings be to prevent this? I've never heard of SET NAMES, it has to be done every query? Really?
AnApprentice
I'm using JQUERY LOAD for the AJAX request, it doesn't have a character set.
AnApprentice
No, `SET NAMES` is run once per connection. It tells MySQL what character set you'd like to receive data in. And **EVERY** request has a character set. Strings are not just magically stored with no encoding simply because JavaScript originated the request. I recommend that you declare the charset as `utf8` everywhere so there's never an issue converting from one encoding to another.
VoteyDisciple
There's no such thing as a "smart quote" in unicode. Any reasonable unicode-aware application will flip apostrophes to be 0x2019 (right-single-quotation-mark), as that is defined by the standard to be preferred over the latin-1 straight-quote-mark (0x0039).
Nick Bastin