Jump to content

Recommended Posts

Need some help here with weird symbols. First off, here is the situation:

I have a form that posts text to a page to be processed. The input is a normal HTML text field.

The php page that processes the data first inputs the text into my mysql database and if successful, sends an email to an email address I've specified.

Sometimes I get weird things like "…let’s" (which is supposed to be ...let's). I've narrowed it down to the fact that some people like to copy text from things like MS WORD into my text field which doesn't email pretty when they use symbols that are not HTML friendly (Examples: "…" instead of "..."{there is a difference} and " ’ " instead of " ' ").

How do I convert their input into HTML friendly text?

 

Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/135377-solved-strange-brew-symbols/
Share on other sites

umm. lol

this is what I got with the same input as before in the example (...let’s)

matrix…let’s

;D

Not quite right I'd say. Any other ideas?

Thanks for the input zanus anyways, I'm going to keep looking following the same train of thought.

How about utf8_decode ?  Encoding it just takes that string and makes it more nasty (I think).

 

I know that solved my issues with the above. Although it is better to design your database to handle them instead of getting them trashed, yea. It worked for me at least.

I was just finished my test of utf8_decode() when I read your post, premiso...  :D

my db handles the the symbols fine, just not the emails.

Little better now. This is what gets emailed now...

?let?s

This detail may or may not be effecting things. here is some of my code for the email:

$body = '<b>Summary: </b>"'.utf8_decode($_POST['Summary']).'"<br>';
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=us-ascii\n";

Where I copied the headers from already had that. I changed it to ISO-8859-1 while using the UTF8_decode() but it still feed me the ?'s instead of symbols.

With UTF8_encode() and utf-8 as my charset i get:

â¦letâs

and still if I have UTF8_decode() and utf-8 as my charset i get it with the ?'s

 

BUT! there is a BUT! I figured it out...

I used htmlspecialchars() with charset=UTF-8 and it worked!

I realized that what I needed was to not make it HTML safe but to make it HTML... lol

 

Thanks for the help guys.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.