Merge pull request #309 from i59/patch-1
[mono.git] / mcs / class / I18N / West / CP1252.cs
index 469e74e8e83e88b10414741645e3f0efc8c2e56d..b0885181980f8de3a3772924a554d0a77d9ec600 100644 (file)
@@ -31,6 +31,7 @@ using System;
 using System.Text;
 using I18N.Common;
 
+[Serializable]
 public class CP1252 : ByteEncoding
 {
        public CP1252()
@@ -97,6 +98,7 @@ public class CP1252 : ByteEncoding
                while(charCount > 0)
                {
                        ch = (int)(chars[charIndex++]);
+                       --charCount;
                        if(ch >= 128) switch(ch)
                        {
                                case 0x0081:
@@ -232,17 +234,18 @@ public class CP1252 : ByteEncoding
                                {
                                        if(ch >= 0xFF01 && ch <= 0xFF5E)
                                                ch -= 0xFEE0;
-                                       else
+                                       else {
 #if NET_2_0
                                                HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+                                               continue;
 #else
                                                ch = 0x3F;
 #endif
+                                       }
                                }
                                break;
                        }
                        bytes[byteIndex++] = (byte)ch;
-                       --charCount;
                        --byteCount;
                }
        }
@@ -403,6 +406,7 @@ public class CP1252 : ByteEncoding
 
 }; // class CP1252
 
+[Serializable]
 public class ENCwindows_1252 : CP1252
 {
        public ENCwindows_1252() : base() {}