Coding Thread, htmlspecialchars / htmlentities - Can't get to work in Coding and Web Development; Hello again
I am having trouble converting special characters when a form is submitted. These include symbols like 'é'. I ...
-
2nd October 2009, 10:57 AM #1
-
-
IDG Tech News
-
2nd October 2009, 11:40 AM #2 Hi Eddie
Using htmlentities() does produce é for me. Have you tried specifying a character set in the third parameter?
-
-
2nd October 2009, 12:20 PM #3
- Rep Power
- 0
[RESOLVED]
Hello,
Thanks a lot, you were right!
Just to clarify for anyone else who has this problem...
I tried the top three character sets and nelow is the results:
$value = "Rosé Wine";
echo htmlentities($value, ENT_QUOTES, "ISO8859-1"); // Output: Rosé Wine
echo htmlentities($value, ENT_QUOTES, "ISO8859-15"); // Output: Rosé Wine
echo htmlentities($value, ENT_QUOTES, "UTF-8"); // Output: Rosé Wine
So you need to set the character set to UTF-8:
echo htmlentities($value, ENT_QUOTES, "UTF-8");
Last edited by eddie; 2nd October 2009 at 12:22 PM.
Reason: Easier to see the correct answer
-
-
2nd October 2009, 12:31 PM #4 Pleased you got it working 
It must be down to the character encoding of the string that is being passed to the function. I used AltGr+E to get the accent and pasted it into a text editor and ISO-8859-1 worked OK, whereas UTF-8 did nothing at all. In your case it's obviously different, but at least it works
-
-
6th October 2009, 09:15 AM #5 You can define UTF-8 for HTML content pagewide by dropping...
Code:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
...into the header of all your pages, and ensuring when you create MySQL databases that you also specify UTF-8 charset.
To make it the default charset for php, head to php.ini on your webserver, and look for...
...and set it to UTF-8 also. But be prepared to change it back as it may break some session calls unless you reinstall the webapp that is calling them.
-
SHARE: 
Similar Threads
-
By tmcd35 in forum Wireless Networks
Replies: 2
Last Post: 8th January 2009, 11:30 PM
-
By djm968 in forum General Chat
Replies: 45
Last Post: 30th June 2008, 11:13 AM
-
By m2d2 in forum General Chat
Replies: 20
Last Post: 21st December 2007, 11:00 PM
-
By beeswax in forum BETT 2013
Replies: 5
Last Post: 6th November 2007, 09:56 PM
-
By ITWombat in forum Blue Skies
Replies: 9
Last Post: 15th July 2007, 01:20 PM
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules