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)
{
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)
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)
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
{
}
// 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");
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)
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
}
}
}