public int GetChars(byte[] bytes, int byteIndex, int byteCount, char[] chars, int charIndex) { int result = 0; while (byteCount > 0) { FFXIIITextTag tag = FFXIIITextTag.TryRead(bytes, ref byteIndex, ref byteCount); if (tag != null) { result += tag.Write(chars, ref charIndex); continue; } FFXIIITextReference reference = FFXIIITextReference.TryRead(bytes, ref byteIndex, ref byteCount); if (reference != null) { result += reference.Write(chars, ref charIndex); continue; } int value = bytes[byteIndex++]; byteCount--; if (value >= 0x80) { value = FFXIIIEncodingMap.ValueToIndex(value, bytes[byteIndex++]); byteCount--; } chars[charIndex++] = _codepage[(short)value]; result++; } return(result); }
public int GetBytes(char[] chars, int charIndex, int charCount, byte[] bytes, int byteIndex) { int result = 0; while (charCount > 0) { FFXIIITextTag tag = FFXIIITextTag.TryRead(chars, ref charIndex, ref charCount); if (tag != null) { result += tag.Write(bytes, ref byteIndex); continue; } FFXIIITextReference reference = FFXIIITextReference.TryRead(chars, ref charIndex, ref charCount); if (reference != null) { result += reference.Write(bytes, ref byteIndex); continue; } short value = _codepage[chars[charIndex++]]; int hight, low; FFXIIIEncodingMap.IndexToValue(value, out hight, out low); if (hight != 0) { bytes[byteIndex++] = (byte)hight; result++; } bytes[byteIndex++] = (byte)low; charCount--; result++; } return(result); }