Jump to content

[SOLVED] Why do curly quotes not come out right?


br3nn4n

Recommended Posts

I've taken this down to the most basic of levels -- inserting the text through PHPMyAdmin.

 

The situation: I have text that was typed in Word, and thus has curly quotes (“ ” etc.).

 

I want to KEEP those curly quotes! They're pretty :P But when I try to save the text to my database and then return it, I get those not-so-pretty question marks!

 

So I tried doing it through PHPMyAdmin and it did the same thing, but at least in PMA they SHOW AS CURLY QUOTES, and not question marks!

 

I'm doing this in UTF-8, which obviously supports those characters. My database is set to a default connection of UTF-8, my db collation is set to UTF-8, my php.ini is set to default of UTF-8...

 

Now, why, even when I insert them through PMA, don't they come out in a UTF-8 encoded page correctly?!?!

 

I'm really frustrated. Can someone PLEASE shed some light? I just want to be able to save an article to my database and have it come out the way it went in with the curly quotes.

 

I'm begging here :P TIA

 

I've taken this down to the most basic of levels -- inserting the text through PHPMyAdmin.

 

The situation: I have text that was typed in Word, and thus has curly quotes (“ ” etc.).

 

I want to KEEP those curly quotes! They're pretty :P But when I try to save the text to my database and then return it, I get those not-so-pretty question marks!

 

So I tried doing it through PHPMyAdmin and it did the same thing, but at least in PMA they SHOW AS CURLY QUOTES, and not question marks!

 

I'm doing this in UTF-8, which obviously supports those characters. My database is set to a default connection of UTF-8, my db collation is set to UTF-8, my php.ini is set to default of UTF-8...

 

Now, why, even when I insert them through PMA, don't they come out in a UTF-8 encoded page correctly?!?!

 

I'm really frustrated. Can someone PLEASE shed some light? I just want to be able to save an article to my database and have it come out the way it went in with the curly quotes.

 

I'm begging here :P TIA

 

Seems that the problem is occurring when you save through the PHP code. Am I correct? If yes, can you please check whether there is any intermediate function exists to convert string to its htmlentities before saving to the DB?

 

Indeed, going backwards you should be able to verify the data in your database using whatever SQL tools available (MySQL GUI tools perhaps?), but as anu suggests you're probably pushing it through some form of encoding before entering it into your db.

 

My rules for entered content are:

1) Verify input

2) Escape output

 

So in the 1st part "verify" you want to make sure that the information is correct, and that all the things you don't allow are stripped or returned as errors.

In the 2nd part "escape" you want to escape all your output so users cannot insert malicious code into your pages. This usually involves using htmlentites on any output data.

Alright, well I'm on a shared host so I don't have access to the mysql console. Maybe I could try this on XAMPP on my linux box and see where it gets me.

 

What's STILL tripping me up is why it inserts correctly into the database and comes out incorrectly. Maybe I have to use "SET names utf-8" ? Just came across that...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.