Merge pull request #1949 from lewurm/fixtype
[mono.git] / mcs / class / I18N / Other / CP1258.cs
index 1537bfcd0b174682eb6f458788bdfeb5bf023865..e56c46733145cc86b55ec995382457ed8a43a202 100644 (file)
@@ -138,15 +138,14 @@ public class CP1258 : ByteEncoding
                                                 byte* bytes, int byteCount)
        {
                int ch;
-               int charIndex;
+               int charIndex = 0;
                int byteIndex = 0;
-#if NET_2_0
                EncoderFallbackBuffer buffer = null;
-#endif
-               for (charIndex=0; charCount > 0; charIndex++, charCount--)
+               while (charCount > 0)
                {
                        ch = (int)(chars[charIndex]);
-                       bool fallback = false;
+                       charIndex++;
+                       charCount--;
                        if(ch >= 128) switch(ch)
                        {
                                case 0x0081:
@@ -286,29 +285,17 @@ public class CP1258 : ByteEncoding
                                        }
                                        else
                                        {
-#if NET_2_0
-                                               //Execute fallback routine and set fallback flag on
                                                HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
-                                               fallback = true;
-#else
-                                               ch = 0x3F;
-#endif
+                                               continue;
                                        }
                                }
                                break;
                        }
                        //Write encoded byte to buffer, if buffer is defined and fallback was not used
-                       if (bytes != null && !fallback)
-                       {
+                       if (bytes != null)
                                bytes[byteIndex] = (byte)ch;
-                       }
-                       
-                       //Bump counters if fallback was not used
-                       if (!fallback)
-                       {
-                               byteIndex++;
-                               byteCount--;
-                       }
+                       byteIndex++;
+                       byteCount--;
                }
                return byteIndex;
        }