2using System.Collections.Generic;
12 private static readonly
char?[] codeToUnicode =
new char?[]
272 private static readonly Dictionary<char, byte> unicodeToCode;
278 unicodeToCode =
new Dictionary<char, byte>();
280 foreach (
char? ch
in codeToUnicode)
283 unicodeToCode[ch.Value] = i;
289 public override int GetByteCount(
char[] chars,
int index,
int count)
294 public override int GetBytes(
char[] chars,
int charIndex,
int charCount,
byte[] bytes,
int byteIndex)
300 if (unicodeToCode.TryGetValue(chars[charIndex++], out
byte b))
301 bytes[byteIndex++] = b;
303 bytes[byteIndex++] = (byte)
'?';
309 public override int GetCharCount(
byte[] bytes,
int index,
int count)
314 public override int GetChars(
byte[] bytes,
int byteIndex,
int byteCount,
char[] chars,
int charIndex)
321 ch = codeToUnicode[bytes[byteIndex++]];
323 chars[charIndex++] = ch.Value;
325 chars[charIndex++] =
'?';
331 public override int GetMaxByteCount(
int charCount)
336 public override int GetMaxCharCount(
int byteCount)