// Get the bytes that result from encoding a character buffer. public unsafe override int GetByteCountImpl(char *chars, int count) { int index = 0; int length = 0; int end = count; DbcsConvert convert = GetConvert(); // 00 00 - FF FF for (int i = 0; i < end; i++, charCount--) { char c = chars[i]; if (c <= 0x80 || c == 0xFF) // ASCII { length++; continue; } byte b1 = convert.u2n[((int)c) * 2]; byte b2 = convert.u2n[((int)c) * 2 + 1]; if (b1 == 0 && b2 == 0) { #if NET_2_0 // FIXME: handle fallback for GetByteCountImpl(). length++; #else length++; #endif } else { length += 2; } } return(length); }
// Get the bytes that result from encoding a character buffer. public override int GetByteCount(char[] chars, int index, int count) { int length = 0; DbcsConvert convert = GetConvert(); // 00 00 - FF FF while (count-- > 0) { char c = chars[index++]; if (c <= 0x80 || c == 0xFF) { // ASCII length++; continue; } byte b1 = convert.u2n[((int)c) * 2]; byte b2 = convert.u2n[((int)c) * 2 + 1]; if (b1 == 0 && b2 == 0) { #if NET_2_0 // FIXME: handle fallback for GetByteCountImpl(). length++; #else length++; #endif } else { length += 2; } } return(length); }
// Get the bytes that result from encoding a character buffer. public unsafe override int GetByteCountImpl( char *chars, int count) { DbcsConvert gb2312 = GetConvert(); int index = 0; int length = 0; while (count-- > 0) { char c = chars[index++]; if (c <= 0x80 || c == 0xFF) // ASCII { length++; continue; } byte b1 = gb2312.u2n[((int)c) * 2 + 1]; byte b2 = gb2312.u2n[((int)c) * 2]; if (b1 == 0 && b2 == 0) { #if NET_2_0 // FIXME: handle fallback for GetByteCount(). #else length++; #endif } else { length += 2; } } return(length); }
// Get the bytes that result from encoding a character buffer. public unsafe override int GetBytesImpl(char *chars, int charCount, byte *bytes, int byteCount) { DbcsConvert convert = GetConvert(); int charIndex = 0; int byteIndex = 0; int end = charCount; EncoderFallbackBuffer buffer = null; 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); }
// Get the bytes that result from encoding a character buffer. public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { int byteCount = bytes.Length; int end = charIndex + charCount; DbcsConvert convert = GetConvert(); EncoderFallbackBuffer buffer = null; // 00 00 - FF FF 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]; byte b2 = convert.u2n[((int)c) * 2 + 1]; 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); }
// Get the bytes that result from encoding a character buffer. public unsafe override int GetBytesImpl(char *chars, int charCount, byte *bytes, int byteCount) { DbcsConvert gb2312 = GetConvert(); int charIndex = 0; int byteIndex = 0; int end = charCount; #if NET_2_0 EncoderFallbackBuffer buffer = null; #endif int origIndex = byteIndex; for (int i = charIndex; i < end; i++, charCount--) { char c = chars[i]; if (c <= 0x80 || c == 0xFF) // ASCII { int offset = byteIndex++; if (bytes != null) { bytes[offset] = (byte)c; } continue; } byte b1 = gb2312.u2n[((int)c) * 2 + 1]; byte b2 = gb2312.u2n[((int)c) * 2]; if (b1 == 0 && b2 == 0) { #if NET_2_0 HandleFallback(ref buffer, chars, ref i, ref charCount, bytes, ref byteIndex, ref byteCount, null); #else int offset = byteIndex++; if (bytes != null) { bytes[offset] = (byte)'?'; } #endif } else { if (bytes != null) { bytes[byteIndex++] = b1; bytes[byteIndex++] = b2; } else { byteIndex += 2; } } } return(byteIndex - origIndex); }
protected int GetBytesInternal(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { int origIndex = byteIndex; int end = charIndex + charCount; int byteCount = bytes != null ? bytes.Length : 0; DbcsConvert gb2312 = GetConvert(); #if NET_2_0 EncoderFallbackBuffer buffer = null; #endif for (int i = charIndex; i < end; i++, charCount--) { char c = chars[i]; if (c <= 0x80 || c == 0xFF) { // ASCII int offset = byteIndex++; if (bytes != null) { bytes[offset] = (byte)c; } continue; } byte b1 = gb2312.u2n[((int)c) * 2 + 1]; byte b2 = gb2312.u2n[((int)c) * 2]; if (b1 == 0 && b2 == 0) { #if NET_2_0 HandleFallback(ref buffer, chars, ref i, ref charCount, bytes, ref byteIndex, ref byteCount, null); #else int offset = byteIndex++; if (bytes != null) { bytes[] = (byte)'?'; } #endif } else { if (bytes != null) { bytes[byteIndex++] = b1; bytes[byteIndex++] = b2; } else { byteIndex += 2; } } } return(byteIndex - origIndex); }
// Get the bytes that result from encoding a character buffer. public unsafe override int GetBytesImpl(char *chars, int charCount, byte *bytes, int byteCount) { int charIndex = 0; int byteIndex = 0; DbcsConvert convert = GetConvert(); #if NET_2_0 EncoderFallbackBuffer buffer = null; #endif // 00 00 - FF FF int origIndex = byteIndex; while (charCount-- > 0) { char c = chars[charIndex++]; if (c <= 0x80 || c == 0xFF) // ASCII { bytes[byteIndex++] = (byte)c; continue; } byte b1 = convert.u2n[((int)c) * 2]; byte b2 = convert.u2n[((int)c) * 2 + 1]; if (b1 == 0 && b2 == 0) { #if NET_2_0 HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount, null); #else bytes[byteIndex++] = (byte)'?'; #endif } else { bytes[byteIndex++] = b1; bytes[byteIndex++] = b2; } } return(byteIndex - origIndex); }
// Get the bytes that result from encoding a character buffer. public override int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { int byteCount = bytes.Length; DbcsConvert gb2312 = GetConvert(); #if NET_2_0 EncoderFallbackBuffer buffer = null; #endif int origIndex = byteIndex; while (charCount-- > 0) { char c = chars[charIndex++]; if (c <= 0x80 || c == 0xFF) { // ASCII bytes[byteIndex++] = (byte)c; continue; } byte b1 = gb2312.u2n[((int)c) * 2 + 1]; byte b2 = gb2312.u2n[((int)c) * 2]; if (b1 == 0 && b2 == 0) { #if NET_2_0 HandleFallback(ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount, null); #else bytes[byteIndex++] = (byte)'?'; #endif } else { bytes[byteIndex++] = b1; bytes[byteIndex++] = b2; } } return(byteIndex - origIndex); }
// Constructor. public KoreanDecoder (DbcsConvert convert, bool useUHC) : base(convert) { this.useUHC = useUHC; }
// Constructor. public KoreanDecoder(DbcsConvert convert, bool useUHC) : base(convert) { this.useUHC = useUHC; }
// Constructor. public CP936Decoder(DbcsConvert convert) : base(convert) { }
// Constructor. public DbcsDecoder(DbcsConvert convert) { this.convert = convert; }
// Constructor. public CP936Decoder (DbcsConvert convert) : base (convert) { }