How to Clean Word text pasted into a text box with PHP
Posted on 2009-04-06
I have a large text box. Users can type content into it, but many are creating their content in Word, or other programs, and pasting it into the text box. Especially with Word, I get some very unpredictable results.
For example, this was entered recently:
Even though we were never in one village for more than a day, or in one hospital for more than an afternoon, IÃ¢ï¿½ï¿½d find myself meeting children whom IÃ¢ï¿½ï¿½d form a bond with. . .. . . and so on
The Ã¢ï¿½ï¿½ represents an apostrophe.
I strip the code of html entities, but how do I get rid of this type of garbage and replace it with the appropriate characters?
Also, line feeds from pasted documents are not predicable. Is there a way to tame them?