Esempio n. 1
0
        // Get the bytes that result from encoding a character buffer.
        public unsafe override int GetBytesImpl(char *chars, int charCount, byte *bytes, int byteCount)
        {
            EncoderFallbackBuffer buffer  = null;
            DbcsConvert           convert = GetConvert();
            int end       = charCount;
            int charIndex = 0;
            int byteIndex = 0;

            int origIndex = byteIndex;

            for (int i = charIndex; i < end; i++, charCount--)
            {
                char c = chars [i];
                if (c <= 0x80 || c == 0xFF)                   // ASCII
                {
                    bytes [byteIndex++] = (byte)c;
                    continue;
                }
                byte b1 = convert.u2n [((int)c) * 2 + 1];
                byte b2 = convert.u2n [((int)c) * 2];
                if (b1 == 0 && b2 == 0)
                {
                    HandleFallback(ref buffer, chars, ref i, ref charCount, bytes, ref byteIndex, ref byteCount, null);
                }
                else
                {
                    bytes [byteIndex++] = b1;
                    bytes [byteIndex++] = b2;
                }
            }
            return(byteIndex - origIndex);
        }
Esempio n. 2
0
        // Get the bytes that result from encoding a character buffer.
        public unsafe override int GetByteCountImpl(char *chars, int charCount)
        {
            DbcsConvert convert = GetConvert();
            int         index   = 0;
            int         length  = 0;

            while (charCount-- > 0)
            {
                char c = chars [index++];
                if (c <= 0x80 || c == 0xFF)                   // ASCII
                {
                    length++;
                    continue;
                }
                byte b1 = convert.u2n [((int)c) * 2 + 1];
                byte b2 = convert.u2n [((int)c) * 2];
                if (b1 == 0 && b2 == 0)
                {
                    // FIXME: handle fallback for GetByteCountImpl().
                    length++;
                }
                else
                {
                    length += 2;
                }
            }
            return(length);
        }
Esempio n. 3
0
 // Constructor.
 public DbcsDecoder(DbcsConvert convert)
 {
     this.convert = convert;
 }
			// Constructor.
			public KoreanDecoder (DbcsConvert convert, bool useUHC) : base (convert)
			{
				this.useUHC = useUHC;
			}
Esempio n. 5
0
 // Constructor.
 public CP950Decoder(DbcsConvert convert) : base(convert)
 {
 }
			// Constructor.
			public DbcsDecoder (DbcsConvert convert)
			{
				this.convert = convert;
			}
			// Constructor.
			public CP950Decoder (DbcsConvert convert) : base (convert)
			{
			}
Esempio n. 8
0
 // Constructor.
 public KoreanDecoder(DbcsConvert convert, bool useUHC) : base(convert)
 {
     this.useUHC = useUHC;
 }