|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
£
I have a form that users can fill in and the content is displayed elsewhere as HTML. For this reason I use htmlentities() to encode any characters that need it. I'm having problems with the £ symbol which is coming out as £ . From Googling for "£" I can see that this is a common problem! I'm guessing it's to do with character sets but this is an area I have no experience in.
Can anyone advise? Thanks, Geoff Last edited by gsoper : January 10th, 2008 at 04:23 PM. Reason: This forum has issues dealing with html entities! |
|
#2
|
||||
|
||||
|
In general, if you see a capital A plus some accent followed by another character - that is, two characters when you expect one - it's a Unicode/UTF-* problem.
£ is Unicode 0xA3 or binary 0b10100011. This was encoded into two bytes using Unicode: the format is 0b110----10------. With padded zeros, 0xA3 is 0b00010100011 which then fits into the two-byte pattern above as 0b1100001010100011, or 0xC2A3. This forms the character string £ that you see. In other words, PHP's utf8_decode() function should fix the problem.
__________________
I'll do something with this space when I remember to. |
|
#3
|
|||
|
|||
|
Quote:
OK, so in the case of htmlentities() should I set the optional charset parameter to 'UTF-8'? Also, should I be adding a charset to the HTML form? Thanks, Geoff |
|
#4
|
||||
|
||||
|
I believe so, yes (to both): your HTML should specify a charset anyways.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > £ |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|