php-i18n Digest 8 Oct 2009 02:33:09 -0000 Issue 427
Topics (messages 1329 through 1330):
Re: iconv - bad encoding
1329 by: Jarosek J.
Re: PHP support of Unicode?
1330 by: Darren Cook
Administrivia:
To subscribe to the digest, e-mail:
[email protected]
To unsubscribe from the digest, e-mail:
[email protected]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
2009/10/5 Moriyoshi Koizumi <[email protected]>
> Are you sure that $text was really encoded in UTF-8 when the output
> was garbled? try dumping bin2hex($text) to see if there's any
> difference.
>
> Regards,
> Moriyoshi
>
> 2009/10/2 Jarosek <[email protected]>:
> > Hello
> >
> > I noticed a problem using iconv, but investigation showed, that this is
> > not exectly the iconv itself, but something like php encoding.
> >
> > From the beginning:
> >
> > a hava an incoming variable $text;
> > it has some Polish diactics 'strona główna'.
> > I expect to remove diactics : 'strona glowna'.
> >
> > So I use iconv: iconv('utf-8', 'us-ascii//TRANSLIT', $text)
> >
> > and unfortunetly i get: 'strona g??wna' ... But only under apache, in
> > browser
> >
> > The same file, command, etc run from bash gives: 'strona glowna' ... OK
> > So i think : "bad config", but double checked and configs are
> > identical... (cli and apache2)
> >
> > Best part: for 2 or 3 times after starting computer (debian), it didn't
> > worker until I did: (apache start && apache stop - not apache restart),
> > then it worked. Now it doesn't work any more. No other config (except
> > php was changed).
> >
> > Any ideas?
> >
> >
> >
> >
> > --
> > PHP Unicode & I18N Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
Thank's for the replay. I needed to set locale to pl_PL.UTF-8 . Strange
think is that it worked without it under the cli... with the same
configuration. Well... it works now.
Best regards
JJ
--- End Message ---
--- Begin Message ---
> encoding. But using PHP with other languages, is that possible? I
> mean, does PHP support Unicode at present time?
Yes, PHP is an excellent choice for unicode work, both for websites and
commandline utilities.
> As I understand it, the following statement is true: "PHP supports
> Unicode only as long as it is encoded as UTF-8"
UTF-8 is usually what you want. Browser and tool and editor support is
most widespread for UTF-8 (especially on linux).
Even using a Microsoft SQL Server database, which I believe was using
UCS-2LE internally, I give it the data in UTF-8, and the database
connection handles the conversion behind the scenes for me.
Be aware if you go down the UTF-16 route you have to start caring about
LE vs. BE, and also need to understand the difference between UTF-16 and
UCS-2.
> Is that correct, or does PHP also support UTF-16?
If using the mbstring extension then UTF-16 is supported (including for
regexes apparently):
http://jp.php.net/manual/en/mbstring.supported-encodings.php
mbstring has been on all shared hosts I've used, so it is usually fine
to rely on it.
Darren
--
Darren Cook, Software Researcher/Developer
http://dcook.org/gobet/ (Shodan Go Bet - who will win?)
http://dcook.org/mlsn/ (Multilingual open source semantic network)
http://dcook.org/work/ (About me and my work)
http://dcook.org/blogs.html (My blogs and articles)
--- End Message ---