string under multibyte locales
The msdn doc states 'strftime returns the number of characters', but prior
to VS2012 it seems to have returned the number of bytes. Locale independent.
The return is however \0-terminated, so strlen is just fine. The behaivor
seems to be persisting in the later VC++ versions as the corresponding
MSDN ticket is closed 'by design'.
See http://connect.microsoft.com/VisualStudio/feedback/details/766205/vs2012-strftime-has-incorrect-return-value-in-vc-11-with-multibyte-codepages#details
. Fixed bug #65066 (Cli server not responsive when responding with 422 http
status code). (Adam)
+- DateTime
+ . Fixed fug #65184 (strftime() returns insufficient-length string under
+ multibyte locales). (Anatol)
+
- GD
. Fixed #65070 (bgcolor does not use the same format as the input image with
imagerotate). (Pierre)
break;
}
}
+#if defined(PHP_WIN32) && _MSC_VER >= 1700
+ /* VS2012 strftime() returns number of characters, not bytes.
+ See VC++11 bug id 766205. */
+ if (real_len > 0) {
+ real_len = strlen(buf);
+ }
+#endif
timelib_time_dtor(ts);
if (!gmt) {
--- /dev/null
+--TEST--
+Test bug #65184 strftime() returns insufficient-length string under multibyte locales
+--SKIPIF--
+<?php
+if (strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') {
+ die("skip Test is valid for Windows");
+}
+?>
+--FILE--
+<?php
+ setlocale(LC_ALL, 'Japanese_Japan.932');
+ $s = strftime('%A');
+
+ for ($i = 0; $i < strlen($s); $i++) {
+ printf("%x ", ord($s[$i]));
+ }
+ echo "\n";
+?>
+===DONE===
+--EXPECT--
+90 85 97 6a 93 fa
+===DONE===