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); }
public int GetByteCount(char[] chars, int index, int count) { int result = 0; byte[] buff = new byte[2]; while (count > 0) { FFXIIITextTag tag = FFXIIITextTag.TryRead(chars, ref index, ref count); if (tag != null) { int offset = 0; result += tag.Write(buff, ref offset); continue; } FFXIIITextReference reference = FFXIIITextReference.TryRead(chars, ref index, ref count); if (reference != null) { result += reference.SizeInBytes; continue; } short value = _codepage[chars[index++]]; int hight, low; FFXIIIEncodingMap.IndexToValue(value, out hight, out low); if (hight != 0) { result++; } result++; count--; } return(result); }
public int GetCharCount(byte[] bytes, int index, int count) { int result = 0; char[] buff = new char[FFXIIITextTag.MaxTagLength]; while (count > 0) { FFXIIITextTag tag = FFXIIITextTag.TryRead(bytes, ref index, ref count); if (tag != null) { int offset = 0; result += tag.Write(buff, ref offset); continue; } FFXIIITextReference reference = FFXIIITextReference.TryRead(bytes, ref index, ref count); if (reference != null) { result += reference.SizeInChars; continue; } byte value = bytes[index++]; count--; if (value >= 0x80) { index++; count--; } result++; } return(result); }