rwmaho Posted October 18, 2014 Share Posted October 18, 2014 (edited) The fancy-looking quotes won't insert into my DB, so I'm trying to convert them to %93 & %94 or normal quotes. Nothing I've tried works. Code: $fancy=" “test” ";$fixed=htmlentities($old, ENT_QUOTES); echo "fancy: $fancy<br>"; echo "fixed: $fixed";Results:fancy: “test”fixed: I want $fixed to be %93test%94, or even "test" would work. Edited October 18, 2014 by rwmaho Quote Link to comment Share on other sites More sharing options...
codefossa Posted October 18, 2014 Share Posted October 18, 2014 (edited) Does mysql_real_escape_string() work? Also, make sure the colation (not sure if I spelt that right) supports it. general_utf8 should be good. Edited October 18, 2014 by Xaotique Quote Link to comment Share on other sites More sharing options...
rwmaho Posted October 18, 2014 Author Share Posted October 18, 2014 (edited) > Does mysql_real_escape_string() work? It didn't help. > general_utf8 should be good My database's collation is "general_utf8_ci" Edited October 18, 2014 by rwmaho Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 18, 2014 Share Posted October 18, 2014 (edited) I ran into a similar situation at one of my jobs a while back. Neither htmlentities() nor htmlspecialchars() with ENT_QUOTES would correctly handle fancy quotes. I think I ended up using str_replace() for opening and closing fancy quotes, opening and closing fancy single quotes, and something else that won't quite come to mind right now. Edited October 18, 2014 by maxxd Quote Link to comment Share on other sites More sharing options...
rwmaho Posted October 18, 2014 Author Share Posted October 18, 2014 Thanks. Yes, str_replace does work. Working Code: $fancy=" “test” ";$fixed=str_replace("“","%93","$fancy");$fixed2=str_replace("”","%94","$fixed");echo "fancy: $fancy<br>";echo "fixed: $fixed2"; Results: fancy: “test”fixed: %93test%94 Quote Link to comment Share on other sites More sharing options...
maxxd Posted October 19, 2014 Share Posted October 19, 2014 It's brute force, but glad it worked for you. Quote Link to comment 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.