ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> php-general
php-general
[PHP] Re: utf8 encoding £ to £ problem
by news NOSPAM 0ixbtqKe other posts by this author
Dec 13 2006 11:29AM messages near this date
Re: [PHP] Error Display | [PHP] Exchange vs IMAP
On Tue, 5 Dec 2006 12:37:48 -0000, "Chris Dean" wrote:

>  I was just wondering if anyone knows why php's utf8_encode
>  function converts the £ symbol into �£

   Yes. The '£' character is a two-octet sequence
in UTF-8. The problem is that you are viewing it
as if it were encoded in ISO-8859-1 (or similar).
These are the octet sequences for the characters
involved:

  Character    ISO-8859-1  UTF-8
  -----------  ----------  -------
  £ (pound)    <a3>         <c2 a3>
  Ã? (A-circ.)  <c2>         <c3 82>


In other words, you are seeing the two characters
<c2> <a3> instead of the one character <c2 a3>.
The fact that <a3>  appears in both encodings is
nothing more than an interesting coincidence.


Example (right):

  <?php
    header ('Content-Type: text/plain; charset=utf-8');
    echo utf8_encode ("\xa3");
  ?> 

Example (wrong):

  <?php
    header ('Content-Type: text/plain; charset=iso-8859-1');
    echo utf8_encode ("\xa3");
  ?> 


--nfe

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

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved