Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Replacing odd characters

Status
Not open for further replies.
What's causing those to come up?

I'm pretty sure this is a unicode issue and not a string format issue, but I could be wrong... either way, perhaps you have an example of the problem in a real situation?
 
i suspect you copied and pasted the text from MS Word or some other wordprocessor that has a "smartquote" or equivalent function.

in the php.net manual there is a search and replace function for this which i reproduce below:

Code:
function clean_string_input($input)
{
   $search = array(
       '/[\x60\x82\x91\x92\xb4\xb8]/i',            // single quotes
       '/[\x84\x93\x94]/i',                        // double quotes
       '/[\x85]/i',                                // ellipsis ...
       '/[\x00-\x0d\x0b\x0c\x0e-\x1f\x7f-\x9f]/i'    // all other non-ascii
   );
   $replace = array(
       '\'',
       '"',
       '...',
       ''
   );
   return preg_replace($search,$replace,$input);
}
 
I get that alot when Mac users send me documents to cut and paste.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top