[thelist] character set word -> ascii

Eric Vitiello evolt at perceive.net
Thu Mar 7 07:52:01 CST 2002


-- m u i n a r [Thu, 07 Mar 2002 14:31:18 -0800]:
>Now this customer wants to copy & paste his texts from
>MS Word into that text area. This leads to problems with
>character sets that are not email/ascii compatible. It's
>not visible in the preview, it's also no problem with our
>Eudora Email setup, but some recipients' servers were
>complaining about wrong character sets.
>
>Is there a function in PHP that can translate these
>characters into plain text somehow? Can you help with
>other options or workarounds / program recommendations?


I would suggest using a regular expression to remove all bad characters:

$this_variable = ereg_replace("[^\x20-\x7E]", "", $original_string);

this will look for any character that has an ascii value not between 32 (x20) and 126 (7E) this covers all standard punctuation, letters, numbers, etc.  (check out http://www.asciitable.com for a list of characters)... it then replaces the bad characters with a blank string.

warning: I'm not a PHP programmer, I'm a Perl programmer. I just looked up the regular expression function, and plugged in a nice regex.

you mileage may vary, and the syntax of the function may be off, but the regular expression is perfect. =)

---
Eric Vitiello
Perceive Designs
<www.perceive.net>




More information about the thelist mailing list