|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-11-25 20:37 UTC] pby_42-web at yahoo dot fr
Description:
------------
Using accent character in the pattern of MessageFormatter::formatMessage return an empty string.
Reproduce code:
---------------
echo (MessageFormatter::formatMessage("fr_FR", "with accent ? ?", array()));
Expected result:
----------------
to display: with accent ? ?
Actual result:
--------------
display nothing
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 17:00:01 2025 UTC |
formatMessage being a static method, it is not possible to use getErrorMessage! I tested with a full object code: $fmt = new MessageFormatter("fr_FR", "with accent ? ?"); $fmt isn't an object, but FALSE Whit $fmt = new MessageFormatter("fr_FR", "with accent a e"); $fmt is an object, and everything works fine. Anyway, I must switch back to PHP 5.2, therefore I will recode a very simple formatter instead of use this class.@pby_42-web at yahoo dot fr: I guess your string is encoded in ISO-8859-15. AFAICT, ICU only accepts strings encoded in UTF-8. Converting your string in UTF-8 and using hexadecimal escape sequences, I got the following result: $ php -a Interactive shell php > echo MessageFormatter::formatMessage("fr_FR", "with accent \xC3\xA9 \xC3\xA0", array()); with accent é à php > So, MessageFormatter DOES accept accentuated letters, you just have to be careful about their encoding. Maybe the documentation should be updated to state this more clearly.