15 static constexpr T* GetMaxStringEnd();
19 static constexpr plUInt16 Utf16BomLE = 0xfeff;
22 static constexpr plUInt16 Utf16BomBE = 0xfffe;
25 static bool IsASCII(plUInt32 uiChar);
28 static bool IsUtf8StartByte(
char iByte);
31 static bool IsUtf8ContinuationByte(
char iByte);
34 static plUInt32 GetUtf8SequenceLength(
char iFirstByte);
37 static plUInt32 ConvertUtf8ToUtf32(
const char* pFirstChar);
40 static plUInt32 GetSizeForCharacterInUtf8(plUInt32 uiCharacter);
46 static plResult MoveToNextUtf8(
const char*& ref_szUtf8, plUInt32 uiNumCharacters = 1);
52 static plResult MoveToNextUtf8(
const char*& ref_szUtf8,
const char* szUtf8End, plUInt32 uiNumCharacters = 1);
58 static plResult MoveToPriorUtf8(
const char*& ref_szUtf8,
const char* szUtf8Start, plUInt32 uiNumCharacters = 1);
61 static bool IsValidUtf8(
const char* szString,
const char* szStringEnd = GetMaxStringEnd<char>());
66 static bool SkipUtf8Bom(
const char*& ref_szUtf8);
72 static bool SkipUtf16BomLE(
const plUInt16*& ref_pUtf16);
78 static bool SkipUtf16BomBE(
const plUInt16*& ref_pUtf16);
81 template <
typename ByteIterator>
82 static plUInt32 DecodeUtf8ToUtf32(ByteIterator& ref_szUtf8Iterator);
85 template <
typename UInt16Iterator>
86 static bool IsUtf16Surrogate(UInt16Iterator& ref_szUtf16Iterator);
89 template <
typename UInt16Iterator>
90 static plUInt32 DecodeUtf16ToUtf32(UInt16Iterator& ref_szUtf16Iterator);
93 template <
typename WCharIterator>
94 static plUInt32 DecodeWCharToUtf32(WCharIterator& ref_szWCharIterator);
97 template <
typename ByteIterator>
98 static void EncodeUtf32ToUtf8(plUInt32 uiUtf32, ByteIterator& ref_szUtf8Output);
101 template <
typename UInt16Iterator>
102 static void EncodeUtf32ToUtf16(plUInt32 uiUtf32, UInt16Iterator& ref_szUtf16Output);
105 template <
typename WCharIterator>
106 static void EncodeUtf32ToWChar(plUInt32 uiUtf32, WCharIterator& ref_szWCharOutput);
109 template <
typename IntType,
typename Container>
112 using InsertionType = IntType;
114 PL_ALWAYS_INLINE
UtfInserter(Container* pContainer) { m_pContainer = pContainer; }
115 PL_ALWAYS_INLINE
void operator++() {}
116 PL_ALWAYS_INLINE
UtfInserter& operator++(
int) {
return *
this; }
117 PL_ALWAYS_INLINE
void operator=(IntType rhs) { m_pContainer->PushBack(rhs); }
118 PL_ALWAYS_INLINE
UtfInserter& operator*() {
return *
this; }
120 Container* m_pContainer;
129 template <
typename Container>
130 static bool RepairNonUtf8Text(
const char* pStartData,
const char* pEndData, Container& out_result);