Re: utf8 encoding £ to £ problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Chris Dean wrote:
> Hi Nunners,
> 
> Just the £ and in my case I need to use that symbol, can't really get round it sensibly with £ 

odd problem - check the output of the output of following ... :

var_dump(
	mb_convert_encoding(html_entity_decode("£"),"UTF-8","ISO-8859-1"),	// this line is sh*t
	html_entity_decode(mb_convert_encoding("£","UTF-8","ISO-8859-1"))		// this works
);

I have no idea where the extra bogus byte is coming from or why but I can suggest the work-around

step 1. replace all '£' with '£' in the string to be converted
step 2. convert the string from ISO-8859-1 to UTF-8
step 3. pass the converted string through html_entity_decode()

this may leave you with the problem that you don't want to decode ALL the html entities in the
string ... in which case you'll have to get your hands a little more dirty.... I would
start by checking out this page:

http://php.net/manual/en/function.get-html-translation-table.php

PS - this is not really a solution, more of a hack - but it might save you a few hairs!

> 
> 
> Chris
> 
> -----Original Message-----
> From: James Nunnerley [mailto:webmaster@xxxxxxxxxxx] 
> Sent: 05 December 2006 13:01
> To: Chris Dean
> Cc: php-general@xxxxxxxxxxxxx
> Subject: RE:  utf8 encoding £ to £ problem
> 
> Hi Chris,
> 
> Do you use £ or £?
> 
> I've had problems uploading onto a linux box for ages, but a straight text £
> never seems to work, so I have to get one of my colleagues to do it
> instead...
> 
> Does that help?
> 
> Nunners
> 
> -----Original Message-----
> From: Chris Dean [mailto:Chris.Dean@xxxxxxxxxxxxxx] 
> Sent: 05 December 2006 12:38
> To: php-general@xxxxxxxxxxxxx
> Subject:  utf8 encoding £ to £ problem
> 
> Hi 
> 
>  
> 
> I was just wondering if anyone knows why php's utf8_encode function converts
> the £ symbol into £
> 
>  
> 
> Is this a bug in php or is it because utf8 doesn't include the £ symbol
> (can't find a quick and easy ref to say if it does or not) and as such the
> function outputs junk?
> 
>  
> 
>  
> 
> Kind Regards
> 
>  
> 
> Chris Dean 
> 
>  
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux