Anyone have any ideas why a JQUERY LOAD Call which has "isn't" in the db is displaying as isnu2019t using JQUERY load?
views:
21answers:
3I'm using JQUERY load, which does that automatically right?
AnApprentice
2010-06-19 17:37:59
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
2010-06-19 17:25:49
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
2010-06-19 17:40:20
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
2010-06-20 17:47:53
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.
- What is the character set used for that column in MySQL?
- 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 aSET NAMES
) - What character set are you declaring the response to be in when replying to the AJAX request?
VoteyDisciple
2010-06-19 17:26:19
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
2010-06-19 18:34:30
I'm using JQUERY LOAD for the AJAX request, it doesn't have a character set.
AnApprentice
2010-06-19 18:34:50
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
2010-06-20 14:20:01
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
2010-06-20 17:50:03