...

View Full Version : Euro woes



NancyJ
08-06-2008, 10:58 AM
I'm having real trouble displaying the euro character on one of the sites I'm working on. Most of my current clients are located in France so I'm familiar with working with euro symbols and accents etc, none of my other sites have this problem.

The database is utf8_general_ci and I have set this in the page:

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

&euro; displays fine but the data is free-text input by the client and I can't expect him to use &euro; instead of . Interestingly - it displays fine in phpMyAdmin too (running on the same server). I've tried using htmlentities in the hope that it would convert to &euro; but no luck and using htmlentities($data,ENT_COMPAT,'UTF-8') actually displays nothing at all.

Any ideas?

abduraooft
08-06-2008, 11:12 AM
Are the other unicode symbols OK?

NancyJ
08-06-2008, 11:36 AM
I tried a bunch of other currency symbols and they all came up as 'FFFD' blocks in FF3 or question marks - except this ₧ which came up as a P

rafiki
08-06-2008, 11:56 AM
Tried str_replace() or urlencode() or rawurlencode()?

NancyJ
08-06-2008, 04:23 PM
str_replace('€','&euro;',$data) works but surely that should be covered in htmlentities? Is there some function I can use to convert all unicode characters to their named equivalents?

derzok
08-06-2008, 04:30 PM
It looks like you're not the only one frustrated with not being able to convert all characters to their html equiv - just grepping the comments on php.net for "euro" I found: http://us3.php.net/manual/en/function.htmlentities.php#84327 and a few decent follow up posts. Hope it helps!

NancyJ
08-06-2008, 04:47 PM
I did some more playing around and this:


echo htmlentities($value,ENT_COMPAT,'UTF-8');

outputs nothing if the $value contains the euro symbol or a pound symbol - presumably others too - I've even set header('Content-type: text/html; charset=utf-8'); as is suggested on the htmlentities page but it seems to just die quietly inside or something when trying to use UTF-8 in htmlentities

oesxyl
08-06-2008, 04:57 PM
I did some more playing around and this:


echo htmlentities($value,ENT_COMPAT,'UTF-8');

outputs nothing if the $value contains the euro symbol or a pound symbol - presumably others too - I've even set header('Content-type: text/html; charset=utf-8'); as is suggested on the htmlentities page but it seems to just die quietly inside or something when trying to use UTF-8 in htmlentities
first step is the form, next is conversion from utf-8 to html entities:

http://www.crazysquirrel.com/computing/general/form-encoding.jspx

I don't think is a proper solution for that, more a hack.

regards

NancyJ
08-06-2008, 05:08 PM
What form?

oesxyl
08-06-2008, 05:16 PM
What form?


&euro; displays fine but the data is free-text input by the client and I can't expect him to use &euro; instead of .
I assume that come from a form, :)

regards

gsnedders
12-28-2008, 06:14 PM
outputs nothing if the $value contains the euro symbol or a pound symbol - presumably others too - I've even set header('Content-type: text/html; charset=utf-8'); as is suggested on the htmlentities page but it seems to just die quietly inside or something when trying to use UTF-8 in htmlentities

If it outputs nothing, then the input isn't a valid UTF-8 string. It's probably being imported incorrectly upon being added (the behaviour of HTML UAs is totally non-obvious with regards to character sets, but websites rely upon the bizzarity so there's little chance of it changing).

bazz
12-28-2008, 11:30 PM
Nancy, would it be agreeable for your clients, if they had to type 'EUR' and then you used a REGEX, to store '&euro;' The when if displaying it on a page (either in their admin pages or a public web page), your scripts could enusre that it always was stored as &euro;

Just a suggestion from a rusty/tired brain.

bazz



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum