[msvc] Update csproj files (#4846)
[mono.git] / mcs / class / I18N / CJK / DbcsEncoding.cs
index e41f7cb9e20df1c256d1c63c9f0d7b1ac3ce68bb..9c644cddf694878404cefe33d332dfbf5ed7c4c1 100644 (file)
@@ -9,14 +9,27 @@ using System;
 using System.Text;
 using I18N.Common;
 
+#if DISABLE_UNSAFE
+using MonoEncoder = I18N.Common.MonoSafeEncoder;
+using MonoEncoding = I18N.Common.MonoSafeEncoding;
+#endif
+
 namespace I18N.CJK
 {
-       internal class DbcsEncoding : Encoding
+       [Serializable]
+       internal abstract class DbcsEncoding : MonoEncoding
        {
-               internal DbcsConvert convert;
-               
-               public DbcsEncoding(int codePage) : base(codePage) {}
-               
+               public DbcsEncoding (int codePage) : this (codePage, 0)
+               {
+               }
+
+               public DbcsEncoding (int codePage, int windowsCodePage)
+                       : base (codePage, windowsCodePage)
+               {
+               }
+
+               internal abstract DbcsConvert GetConvert ();
+
                // Get the number of bytes needed to encode a character buffer.
                public override int GetByteCount(char[] chars, int index, int count)
                {
@@ -30,6 +43,7 @@ namespace I18N.CJK
                        return GetBytes(chars, index, count, buffer, 0);
                }
                
+/*
                // Get the bytes that result from encoding a character buffer.
                public override int GetBytes(char[] chars, int charIndex, int charCount,
                                             byte[] bytes, int byteIndex)
@@ -46,6 +60,7 @@ namespace I18N.CJK
                                throw new ArgumentOutOfRangeException("byteIndex", Strings.GetString("ArgRange_Array"));
                        return 0; // For subclasses to implement
                }
+*/
                
                // Get the number of characters needed to decode a byte buffer.
                public override int GetCharCount(byte[] bytes, int index, int count)
@@ -96,12 +111,6 @@ namespace I18N.CJK
                        return byteCount;
                }
                
-               // Get a decoder that handles a rolling state.
-               public override Decoder GetDecoder()
-               {
-                       return new DbcsDecoder(convert);
-               }
-               
                // Determine if this encoding can be displayed in a Web browser.
                public override bool IsBrowserDisplay
                {
@@ -127,20 +136,17 @@ namespace I18N.CJK
                }
                
                // Decoder that handles a rolling state.
-               internal class DbcsDecoder : Decoder
+               internal abstract class DbcsDecoder : Decoder
                {
                        protected DbcsConvert convert;
-                       internal int lastByte;
                        
                        // Constructor.
                        public DbcsDecoder(DbcsConvert convert)
                        {
                                this.convert = convert;
-                               this.lastByte = 0;
                        }
                        
-                       // Override inherited methods.
-                       public override int GetCharCount(byte[] bytes, int index, int count)
+                       internal void CheckRange (byte[] bytes, int index, int count)
                        {
                                if (bytes == null)
                                        throw new ArgumentNullException("bytes");
@@ -148,11 +154,9 @@ namespace I18N.CJK
                                        throw new ArgumentOutOfRangeException("index", Strings.GetString("ArgRange_Array"));
                                if (count < 0 || count > (bytes.Length - index))
                                        throw new ArgumentOutOfRangeException("count", Strings.GetString("ArgRange_Array"));
-                               char[] buffer = new char[count * 2];
-                               return GetChars(bytes, index, count, buffer, 0);
                        }
-                       
-                       public override int GetChars(byte[] bytes, int byteIndex, int byteCount,
+
+                       internal void CheckRange (byte[] bytes, int byteIndex, int byteCount,
                                                     char[] chars, int charIndex)
                        {
                                if (bytes == null)
@@ -165,7 +169,6 @@ namespace I18N.CJK
                                        throw new ArgumentOutOfRangeException("byteCount", Strings.GetString("ArgRange_Array"));
                                if (charIndex < 0 || charIndex > chars.Length)
                                        throw new ArgumentOutOfRangeException("charIndex", Strings.GetString("ArgRange_Array"));
-                               return 0; // For subclasses to implement
                        }
                }
        }