private int GetCharCount(byte[] bytes, int index, int count, SuperDecoder decoder) { int charCount = 0; ushort u; char c; for (int i = 0; i < count; index++, charCount++, i++) { u = 0; if (decoder != null && decoder.pendingByte != 0) { u = decoder.pendingByte; decoder.pendingByte = 0; } u = (ushort)(u << 8 | bytes[index]); c = _dbcsToUnicode[u]; if (c == LEAD_BYTE_CHAR) { if (i < count - 1) { index++; i++; } else if (decoder != null) { decoder.pendingByte = bytes[index]; return charCount; } } } return charCount; }
private int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex, SuperDecoder decoder) { int charCount = 0; ushort u; char c; for (int i = 0; i < byteCount; byteIndex++, charIndex++, charCount++, i++) { u = 0; if (decoder != null && decoder.pendingByte != 0) { u = decoder.pendingByte; decoder.pendingByte = 0; } u = (ushort)(u << 8 | bytes[byteIndex]); c = _dbcsToUnicode[u]; if (c == LEAD_BYTE_CHAR) { if (i < byteCount - 1) { byteIndex++; i++; u = (ushort)(u << 8 | bytes[byteIndex]); c = _dbcsToUnicode[u]; } else if (decoder == null) { c = '\0'; } else { decoder.pendingByte = bytes[byteIndex]; return charCount; } } if (c == 0 && u != 0) chars[charIndex] = '?'; else chars[charIndex] = c; } return charCount; }