Unwanted characters (–) in mysql records [solved]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Steve Mellor
Forum Commoner
Posts: 49
Joined: Thu Aug 02, 2007 8:18 am

Unwanted characters (–) in mysql records [solved]

Post 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
Last edited by Steve Mellor on Wed Sep 12, 2007 4:39 am, edited 1 time in total.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

It seems you're outputting utf-8 encoded data as latin1. iconv() to the rescue.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

– is a dash by the way, not a quote mark. Utf8 left quote mark looks like “ when viewed in latin1
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post 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.
Steve Mellor
Forum Commoner
Posts: 49
Joined: Thu Aug 02, 2007 8:18 am

Post 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.
Post Reply