mjurmann Posted March 12, 2008 Share Posted March 12, 2008 Hello, I have a string that contains the ™ symbol. When the string is echoed, instead of the ™ symbol appearing, I see a "?" (question mark). I'm working on a project for someone and I don't want to have to enter in the special codes for these special characters, so is there any way to decode that ™ symbol within the string and then have it echo out the ™ rather than echoing out a "?" ? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/ Share on other sites More sharing options...
Demonic Posted March 12, 2008 Share Posted March 12, 2008 Look up "htmlspecialchars()" ? Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490533 Share on other sites More sharing options...
soycharliente Posted March 12, 2008 Share Posted March 12, 2008 Maybe htmlspecialchars() Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490534 Share on other sites More sharing options...
mjurmann Posted March 12, 2008 Author Share Posted March 12, 2008 Look up "htmlspecialchars()" ? No luck, that didn't work. I'm still getting the "?" (question mark) instead of the actual ™ symbol. Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490538 Share on other sites More sharing options...
effigy Posted March 12, 2008 Share Posted March 12, 2008 Perhaps it is stored in UTF-8 and your META needs to conform? Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490540 Share on other sites More sharing options...
mjurmann Posted March 12, 2008 Author Share Posted March 12, 2008 Perhaps it is stored in UTF-8 and your META needs to conform? Here is my META information for that document: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490543 Share on other sites More sharing options...
Demonic Posted March 12, 2008 Share Posted March 12, 2008 Humm...try htmlentities(..,ENT_QUOTES, 'UTF-8'); Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490559 Share on other sites More sharing options...
mjurmann Posted March 12, 2008 Author Share Posted March 12, 2008 Humm...try htmlentities(..,ENT_QUOTES, 'UTF-8'); I tried this and nothing echos from the string. It comes up with an empty echo. The code I used: $rowExcerptPR = htmlentities($rowExcerptPR,ENT_QUOTES, 'UTF-8'); Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490564 Share on other sites More sharing options...
effigy Posted March 12, 2008 Share Posted March 12, 2008 Is this string actually in your code, or being pulled from somewhere else? Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490581 Share on other sites More sharing options...
mjurmann Posted March 12, 2008 Author Share Posted March 12, 2008 Is this string actually in your code, or being pulled from somewhere else? Its being pulled from a WordPress database using a mySQL query. Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490584 Share on other sites More sharing options...
haku Posted March 12, 2008 Share Posted March 12, 2008 What is the encoding in your database? Your meta tag has to have the same charset. Also, you will have to ensure that the default_charset in your php.ini is set to that same charset. Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490587 Share on other sites More sharing options...
mjurmann Posted March 12, 2008 Author Share Posted March 12, 2008 This doesn't seem to be working. Fortunately, I only believe that they will be using the ™ symbol and therefore I'd like to do a simple find and replace within the string (find ™, replace with ™). Can someone please point me to the correct function to do this? Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490596 Share on other sites More sharing options...
mjurmann Posted March 12, 2008 Author Share Posted March 12, 2008 I asked the last question too quickly. I found the answer (str_replace). Thanks anyways to everyone. Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490600 Share on other sites More sharing options...
soycharliente Posted March 12, 2008 Share Posted March 12, 2008 You're only doing that in one specific instance correct? If you applied that function to entire post or all the text on the page, you could possibly screw up words like leftmost, hitman, batman, litmus, nutmeg, oatmeal, etc. I could go on Link to comment https://forums.phpfreaks.com/topic/95821-simple-php-command-to-convert-special-characters/#findComment-490602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.