2005-11-30 Atsushi Enomoto <atsushi@ximian.com>
[mono.git] / mcs / class / I18N / West / CP1252.cs
index 291ef914bf45fbdf17d9265f0496250ea93aa168..469e74e8e83e88b10414741645e3f0efc8c2e56d 100644 (file)
@@ -28,6 +28,7 @@ namespace I18N.West
 {
 
 using System;
+using System.Text;
 using I18N.Common;
 
 public class CP1252 : ByteEncoding
@@ -84,10 +85,15 @@ public class CP1252 : ByteEncoding
                '\u00FC', '\u00FD', '\u00FE', '\u00FF', 
        };
 
-       protected override void ToBytes(char[] chars, int charIndex, int charCount,
-                                       byte[] bytes, int byteIndex)
+       protected unsafe override void ToBytes(char* chars, int charCount,
+                                       byte* bytes, int byteCount)
        {
                int ch;
+               int charIndex = 0;
+               int byteIndex = 0;
+#if NET_2_0
+               EncoderFallbackBuffer buffer = null;
+#endif
                while(charCount > 0)
                {
                        ch = (int)(chars[charIndex++]);
@@ -227,15 +233,21 @@ public class CP1252 : ByteEncoding
                                        if(ch >= 0xFF01 && ch <= 0xFF5E)
                                                ch -= 0xFEE0;
                                        else
+#if NET_2_0
+                                               HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
+#else
                                                ch = 0x3F;
+#endif
                                }
                                break;
                        }
                        bytes[byteIndex++] = (byte)ch;
                        --charCount;
+                       --byteCount;
                }
        }
 
+       /*
        protected override void ToBytes(String s, int charIndex, int charCount,
                                        byte[] bytes, int byteIndex)
        {
@@ -387,6 +399,7 @@ public class CP1252 : ByteEncoding
                        --charCount;
                }
        }
+       */
 
 }; // class CP1252