php-src/ext/intl/tests/bug69374.phpt
Mic 527ddacd20 Fixed bug #69374 IntlDateFormatter formatObject returns wrong utf8 value
Relying on invariant strings is a mistake. Not only UTF-8, but also
many charsets are not single byte. Actual date formats can be mixed
with arbitrary strings, and this can bring erroneous results in the
out. Thus, instead it is more convenient to say, that a format string
can consist either on UTF-8 or on pure ASCII as its subset. This is
what is currently being done in other classes like Formatter, etc.
as well.
2016-06-02 22:27:48 +02:00

25 lines
781 B
PHP

--TEST--
IntlDateFormatter::formatObject(): returns wrong utf8 value when $format param is utf8 string pattern.
--SKIPIF--
<?php
if (!extension_loaded('intl')) die('skip intl extension not enabled'); ?>
<?php if (version_compare(INTL_ICU_VERSION, '50.1.2') < 0) die('skip for ICU >= 51.1.2'); ?>
--FILE--
<?php
$millitimestamp = 1428133423941.0; // 14:43:43 April 04 2015
$pattern1 = '\'tháng\' MM, y'; // yMM format for Vietnamese
$pattern2 = 'y년 MMM'; // yMM format for Korean
$date = IntlCalendar::createInstance('Asia/Ho_Chi_Minh');
$date->setTime($millitimestamp);
echo IntlDateFormatter::formatObject($date, $pattern1, 'vi_VN'), "\n";
echo IntlDateFormatter::formatObject ($date, $pattern2, 'ko_KR'), "\n";
?>
==DONE==
--EXPECTF--
tháng 04, 2015
2015년 4월
==DONE==