Re: [PHP] mb_convert_encoding converting to ASCII instead of UTF-8

[email protected] ("Eric Butera")
Newsgroups php.general
Message-ID <[email protected]>
On Wed, Apr 23, 2008 at 10:40 AM, Robert William Vesterman
<[email protected]> wrote:
> I've run into a problem where mb_convert_encoding seems to be converting to
> ASCII, even though I'm telling it to convert to UTF-8.  This is with PHP
> version 4.3.11.
>
>  I had been asking it to convert from "auto" to UTF-8, so at first I thought
> maybe "auto" was not the right choice.  So I called "mb_detect_encoding" to
> see the format of what I was trying to convert; it said it was already UTF-8
> (before I did the conversion).
>  So then I thought maybe I got the "from" and "to" parameters backwards
> (although I was confident I was following the documentation), so I changed
> mb_convert_encoding to use "UTF-8" as /both/ the from and to.
>
>  It still converts to ASCII.
>
>  I understand that, given that it's already UTF-8, I don't need to convert
> it to UTF-8.  But other things that I receive might /not/ be UTF-8, so I am
> still concerned with this.
>
>  Sample code:
>
>   <html><head><title>Minnie</title></head><body><p>
>   <?php
>   $x = $_REQUEST['Minnie'];
>   echo $x . ' ... ' . mb_detect_encoding ( $x ) . '<br/>';
>   $x = mb_convert_encoding ( $x, "UTF-8", "UTF-8" );
>   echo $x . ' ... ' . mb_detect_encoding ( $x ) . '<br/>';
>   ?>
>   </p></body></html>
>
>  Output, when called with URL parameter "Minnie=Miñoso":
>
>   Miñoso ... UTF-8
>   Mioso ... ASCII
>
>  Then I changed the "from" so that I could try converting from something
> other than UTF-8:
>
>   $x = mb_convert_encoding ( $x, "UTF-8", mb_detect_encoding ( $x ) );
>
>  And now, output when called with "Minnie=Mouse":
>
>   Mouse ... ASCII
>   Mouse ... ASCII
>
>  Does anyone have any idea what's going on here? Am I doing something wrong?
>
>  Thanks in advance for any help.
>
>
>  --
>  PHP General Mailing List (http://www.php.net/)
>  To unsubscribe, visit: http://www.php.net/unsub.php
>
>

#1 Upgrade your php version.  Yours is over 3 years old [1].

#2 Maybe something here [2] will help you.


[1] http://www.php.net/ChangeLog-4.php#4.3.11
[2] http://www.phpwact.org/php/i18n/charsets
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.