]> granicus.if.org Git - php/commitdiff
Fixed bug #60306 (Characters lost while converting from cp936 to utf8)
authorXinchen Hui <laruence@php.net>
Fri, 18 Nov 2011 08:50:29 +0000 (08:50 +0000)
committerXinchen Hui <laruence@php.net>
Fri, 18 Nov 2011 08:50:29 +0000 (08:50 +0000)
NEWS
ext/mbstring/libmbfl/filters/mbfilter_cp936.c
ext/mbstring/tests/bug60306.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index ef552e452d92adfdecc14e8baedae2799fda829a..1ec9aca03ae1e097dad5ae0922d89a19f6f6cc19 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -35,6 +35,10 @@ PHP                                                                        NEWS
   . Fixed bug #54682 (Tidy::diagnose() NULL pointer dereference).
     (Maksymilian Arciemowicz, Felipe)
 
+- Mbstring
+  . Fixed bug #60306 (Characters lost while converting from cp936 to utf8).
+    (Laruence)
+
 -CLI SAPI:
   . Fixed bug #60159 (Router returns false, but POST is not passed to requested
     resource). (Laruence)
index a3baeabdfc8fbb799ba41da621c71b2ea3c321cc..caf26e329b2f7ed32de0a305e3b7148882d6f1f8 100644 (file)
@@ -103,7 +103,7 @@ int
 mbfl_filt_conv_cp936_wchar(int c, mbfl_convert_filter *filter)
 {
        int k;
-       int c1, c2, w;
+       int c1, c2, w = -1;
 
        switch (filter->status) {
        case 0:
@@ -304,5 +304,3 @@ static int mbfl_filt_ident_cp936(int c, mbfl_identify_filter *filter)
 
        return c;
 }
-
-
diff --git a/ext/mbstring/tests/bug60306.phpt b/ext/mbstring/tests/bug60306.phpt
new file mode 100644 (file)
index 0000000..f7969e1
--- /dev/null
@@ -0,0 +1,11 @@
+--TEST--
+Bug #60306 (Characters lost while converting from cp936 to utf8)
+--SKIPIF--
+<?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
+--FILE--
+<?php
+$s = "洪仁玕";
+var_dump($s === mb_convert_encoding(mb_convert_encoding($s, "cp936", "utf8"), "utf8", "cp936"));
+?>
+--EXPECT--
+bool(true)