Brian W Posted December 3, 2008 Share Posted December 3, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/135377-solved-strange-brew-symbols/ Share on other sites More sharing options...
Zane Posted December 3, 2008 Share Posted December 3, 2008 going on a limb here but try utf8_encode Quote Link to comment https://forums.phpfreaks.com/topic/135377-solved-strange-brew-symbols/#findComment-705135 Share on other sites More sharing options...
Brian W Posted December 3, 2008 Author Share Posted December 3, 2008 umm. lol this is what I got with the same input as before in the example (...let’s) matrix…let’s 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. Quote Link to comment https://forums.phpfreaks.com/topic/135377-solved-strange-brew-symbols/#findComment-705148 Share on other sites More sharing options...
premiso Posted December 3, 2008 Share Posted December 3, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/135377-solved-strange-brew-symbols/#findComment-705151 Share on other sites More sharing options...
Brian W Posted December 3, 2008 Author Share Posted December 3, 2008 I was just finished my test of utf8_decode() when I read your post, premiso... 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"; Quote Link to comment https://forums.phpfreaks.com/topic/135377-solved-strange-brew-symbols/#findComment-705162 Share on other sites More sharing options...
premiso Posted December 3, 2008 Share Posted December 3, 2008 Its probably the us-sacii charset. If that was utf-8 I bet you wouldnt have that problem. Is there a reason you are using the us-ascii charset? Quote Link to comment https://forums.phpfreaks.com/topic/135377-solved-strange-brew-symbols/#findComment-705165 Share on other sites More sharing options...
Brian W Posted December 3, 2008 Author Share Posted December 3, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/135377-solved-strange-brew-symbols/#findComment-705175 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.