lostprophetpunk Posted August 27, 2009 Share Posted August 27, 2009 I have a huge body of text in my blog, but the thing is...it contains loads of these little � symbols. I was wondering if anyone knew of a solution to remove them from the text...and they appear after a " character. If anyone could help, that would be nice. Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/ Share on other sites More sharing options...
ignace Posted August 27, 2009 Share Posted August 27, 2009 $string = str_replace(0xFFFD, '', $string); Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907366 Share on other sites More sharing options...
MadTechie Posted August 27, 2009 Share Posted August 27, 2009 You have an encoding issue, try changing your character encoding to UTF-8 in the head section of the html add <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907369 Share on other sites More sharing options...
lostprophetpunk Posted August 27, 2009 Author Share Posted August 27, 2009 You have an encoding issue, try changing your character encoding to UTF-8 in the head section of the html add <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> That is already the encoding I have on the website. Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907376 Share on other sites More sharing options...
ignace Posted August 27, 2009 Share Posted August 27, 2009 You can ofcourse also try to trim the data but this only works if the FF FD appears at the beginning or the end of the string. Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907381 Share on other sites More sharing options...
JonnoTheDev Posted August 27, 2009 Share Posted August 27, 2009 This doesn't always work. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> I usually force with a header at the top of every script (or common include): header('Content-Type: text/html; charset=UTF-8'); If you have funny characters in your database you could use mbstring extensions to convert the encoding: $string = "abc"; print mb_convert_encoding($string, "UTF-8", "auto"); Prior to inserting records in your database run the following query. Best straight after a connection has been established. mysql_query("SET NAMES UTF8"); Do not attempt to convert characters. Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907386 Share on other sites More sharing options...
lostprophetpunk Posted August 27, 2009 Author Share Posted August 27, 2009 None of the methods have worked. The symbol showed up after I had posted it through my blog system, in which I copied the text from a text document I had created in word 07. Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907405 Share on other sites More sharing options...
JonnoTheDev Posted August 27, 2009 Share Posted August 27, 2009 which I copied the text from a text document I had created in word 07 What does the character look like in your database? Microsoft uses non standard encodings. Do you have some sort of javascript HTML editor that you are using to insert your blog content? If so it will be retaining the MS Word formatting. You should paste the text from Word into a text editor first (i.e. notepad) and then copy into your textarea for insert to your blog. Not directly from MS word! If you are using a javascript editor to insert your blogs such as http://www.fckeditor.net/ there should be a config setting to force pasted content as plain text and not retain formatting (at least this one does). You will never be able to replace characters that have come from MS Word, trust me I have tried. Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907406 Share on other sites More sharing options...
lostprophetpunk Posted August 27, 2009 Author Share Posted August 27, 2009 which I copied the text from a text document I had created in word 07 What does the character look like in your database? Microsoft uses non standard encodings. Do you have some sort of javascript HTML editor that you are using to insert your blog content? If so it will be retaining the MS Word formatting. You should paste the text from Word into a text editor first (i.e. notepad) and then copy into your textarea for insert to your blog. Not directly from MS word! If you are using a javascript editor to insert your blogs such as http://www.fckeditor.net/ there should be a config setting to force pasted content as plain text and not retain formatting (at least this one does). You will never be able to replace characters that have come from MS Word, trust me I have tried. I am not using javascript at all in my blog system. I have made it so that it mysql_real_escape_string(htmlentities()); the content befor entering the database. Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907408 Share on other sites More sharing options...
JonnoTheDev Posted August 27, 2009 Share Posted August 27, 2009 OK, then just refrain from pasting directly from Word. As I said paste into a text editor and then into your textarea for insert. Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907412 Share on other sites More sharing options...
lostprophetpunk Posted August 27, 2009 Author Share Posted August 27, 2009 Well, I have it fixed now. I pasted it into notepad++ and edited it there. Here is the result. Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907414 Share on other sites More sharing options...
JonnoTheDev Posted August 27, 2009 Share Posted August 27, 2009 OK, MS Word is the devils work as far as HTML encoding. An alternate solution could be to disable the default character encoding in your apache configuration. Look for: AddDefaultCharset And comment it out #AddDefaultCharset Restart apache Quote Link to comment https://forums.phpfreaks.com/topic/172094-the-%EF%BF%BD-symbol/#findComment-907420 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.