[RESOLVED]pasting from MS Word into a form

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
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

[RESOLVED]pasting from MS Word into a form

Post by andym01480 »

Copying text from a received email into a form that runs a (secure!) php mail script resulted in this
You don’t
Where a ' got translated badly.

I can see that you would need to define the character set of the page that holds the form - but pasted stuff will still go bad...

Code: Select all

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- within a wordpress plugin!

What is the best way of stopping that kind of nastiness?
Last edited by andym01480 on Wed May 05, 2010 3:43 am, edited 1 time in total.
User avatar
flying_circus
Forum Regular
Posts: 732
Joined: Wed Mar 05, 2008 10:23 pm
Location: Sunriver, OR

Re: Weird characters in an email script

Post by flying_circus »

What is the character set of your received email?
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: Weird characters in an email script

Post by andym01480 »

Couldn't tell you offhand - but it came from a pc doofus, so whatever is out of the box UK English office 2003

Is there a way of sorting any other character set, because the same happens copying and pasting from Word docs.
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: Weird characters in an email script

Post by andym01480 »

Code: Select all

 mb_convert_encoding(nl2br($_POST['text']), 'HTML-ENTITIES', 'UTF-8') 
has done the trick nicely
User avatar
timWebUK
Forum Contributor
Posts: 239
Joined: Thu Oct 29, 2009 6:48 am
Location: UK

Re: [RESOLVED]pasting from MS Word into a form

Post by timWebUK »

You can always copy and paste into Notepad, then into the form.
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Re: [RESOLVED]pasting from MS Word into a form

Post by andym01480 »

You could, but that doesn't make for great usability!

The above posted code snippet worked for a piece of text with heading1, curly quotes and bullets, so will do me
Post Reply