Page 1 of 1

Unwanted characters (–) in mysql records [solved]

Posted: Mon Sep 10, 2007 8:29 am
by Steve Mellor
Hi there,

I have inherited a database which displays some funny characters when you echo the fields. In particular it seams to have placed – where a quote mark is meant to go and ’ in place of a apostrophe.

Does anyone have any ideas how I can clean this up. I've tried 'str_replace' and it's various alternates with no luck. I assume it is a character set problem on retrieval but that still doesn't leave me with any way of sorting the problem out.

All help will be greatly appreciated.

All the best

Steve

Posted: Mon Sep 10, 2007 2:25 pm
by Weirdan
It seems you're outputting utf-8 encoded data as latin1. iconv() to the rescue.

Posted: Mon Sep 10, 2007 2:39 pm
by Weirdan
– is a dash by the way, not a quote mark. Utf8 left quote mark looks like “ when viewed in latin1

Posted: Mon Sep 10, 2007 3:12 pm
by Kieran Huggins
I would strongly recommend switching everything to UTF-8. That's one design decision that can save you countless hours of problems, IME.

Posted: Wed Sep 12, 2007 4:41 am
by Steve Mellor
Thanks for that. Switched to UTF-8 and it solved everything. I have a 'template' for all of the sites I create and I've changed that now as well. Seams like a good idea.