Changed overlong byte to be processed again.
authorMarcos Henrich <marcos.henrich@xamarin.com>
Tue, 2 Sep 2014 15:10:19 +0000 (23:10 +0800)
committerMarcos Henrich <marcos.henrich@xamarin.com>
Tue, 2 Sep 2014 15:14:09 +0000 (23:14 +0800)
The byte is processed again because it can be the begin of a new multi-byte encoded character.

mcs/class/corlib/System.Text/UTF8Encoding.cs

index 9c8ed4dcbb7f17410ae6082c2552eadd6d67f001..1ea7a9ea86a810057f6af52dc673bbff9b0cba86 100644 (file)
@@ -547,6 +547,7 @@ fail_no_space:
                                                        }
                                                        if (overlong) {
                                                                length += Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar);
+                                                               --byteIndex; //process byte again
                                                        }
                                                        else if ((leftBits & 0xF800) == 0xD800) {
                                                                // UTF-8 doesn't use surrogate characters
@@ -775,6 +776,7 @@ fail_no_space:
                                                        }
                                                        if (overlong) {
                                                                Fallback (provider, ref fallbackBuffer, bytes, byteIndex - leftSoFar, leftSoFar, chars, ref posn);
+                                                               --byteIndex; //process byte again
                                                        }
                                                        else if ((leftBits & 0xF800) == 0xD800) {
                                                                // UTF-8 doesn't use surrogate characters