6#include "GenericPlatform/GenericPlatformStricmp.h"
7#include "Templates/EnableIf.h"
8#include "Traits/IsCharEncodingCompatibleWith.h"
9#include "Traits/IsCharEncodingSimplyConvertibleTo.h"
10#include "Traits/IsCharType.h"
11#include "Traits/IsFixedWidthCharEncoding.h"
31 ARK_API UTF8CHAR*
Convert(UTF8CHAR* Dest, int32 DestLen,
const WIDECHAR* Src);
32 ARK_API UTF8CHAR*
Convert(UTF8CHAR* Dest, int32 DestLen,
const WIDECHAR* Src, int32 SrcLen);
37 ARK_API ANSICHAR*
Convert(ANSICHAR* Dest, int32 DestLen,
const UTF8CHAR* Src);
38 ARK_API ANSICHAR*
Convert(ANSICHAR* Dest, int32 DestLen,
const UTF8CHAR* Src, int32 SrcLen);
39 ARK_API WIDECHAR*
Convert(WIDECHAR* Dest, int32 DestLen,
const UTF8CHAR* Src);
40 ARK_API WIDECHAR*
Convert(WIDECHAR* Dest, int32 DestLen,
const UTF8CHAR* Src, int32 SrcLen);
47#define HIGH_SURROGATE_START_CODEPOINT ((uint16)0xD800
)
48#define HIGH_SURROGATE_END_CODEPOINT ((uint16)0xDBFF
)
49#define LOW_SURROGATE_START_CODEPOINT ((uint16)0xDC00
)
50#define LOW_SURROGATE_END_CODEPOINT ((uint16)0xDFFF
)
51#define ENCODED_SURROGATE_START_CODEPOINT ((uint32)0x10000
)
52#define ENCODED_SURROGATE_END_CODEPOINT ((uint32)0x10FFFF
)
54#define UNICODE_BOGUS_CHAR_CODEPOINT '?'
58
59
63
64
65 template <
typename Encoding>
66 UE_DEPRECATED(5.1,
"FPlatformString::IsFixedWidthEncoding<T>() has been deprecated in favor of TIsFixedWidthCharEncoding_V<T>")
69 return TIsFixedWidthCharEncoding_V<Encoding>;
73
74
75
76
77
78 template <
typename SrcEncoding,
typename DestEncoding>
79 UE_DEPRECATED(5.1,
"FPlatformString::IsCharEncodingCompatibleWith<A, B>() has been deprecated in favor of TIsCharEncodingCompatibleWith_V<A, B>")
82 return TIsCharEncodingCompatibleWith_V<SrcEncoding, DestEncoding>;
86
87
88 template <
typename SourceEncoding,
typename DestEncoding>
89 UE_DEPRECATED(5.1,
"FPlatformString::IsCharEncodingSimplyConvertibleTo<A, B>() has been deprecated in favor of TIsCharEncodingSimplyConvertibleTo_V<A, B>")
92 return TIsCharEncodingSimplyConvertibleTo_V<SourceEncoding, DestEncoding>;
96
97
98
99
100
101 template <
typename DestEncoding,
typename SourceEncoding>
106 static_assert(
TIsCharType<SourceEncoding>::Value,
"Source encoding is not a char type");
107 static_assert(
TIsCharType<DestEncoding >::Value,
"Destination encoding is not a char type");
110 static_assert(TIsFixedWidthCharEncoding_V<SourceEncoding>,
"Source encoding is not fixed-width");
112 if constexpr (TIsCharEncodingSimplyConvertibleTo_V<SourceEncoding, DestEncoding>)
117 else if constexpr (!TIsFixedWidthCharEncoding_V<DestEncoding>)
122 else if constexpr (std::is_same_v<DestEncoding, ANSICHAR>)
124 return (uint32)Codepoint <= 0x7F;
130 static_assert(
sizeof(SourceEncoding) == 4 &&
sizeof(DestEncoding) == 2,
"Unimplemented conversion");
133 return (uint32)Codepoint <= 0xFFFF;
139
140
141
142
143 template <
typename Encoding>
156
157
162
163
164 template <
typename T>
165 struct UE_DEPRECATED(5.0,
"TIsFixedWidthEncoding is deprecated, use TIsFixedWidthCharEncoding_V<T> instead.") TIsFixedWidthEncoding
167 enum { Value = TIsFixedWidthCharEncoding_V<T> };
172
173
174
175
176
177
178
179 template <
typename EncodingA,
typename EncodingB>
180 struct UE_DEPRECATED(5.0,
"TAreEncodingsCompatible is deprecated, use TIsCharEncodingCompatibleWith_V<SrcEncoding, DestEncoding> instead.") TAreEncodingsCompatible
182 enum { Value = TIsFixedWidthCharEncoding_V<EncodingA> && TIsFixedWidthCharEncoding_V<EncodingB> &&
sizeof(EncodingA) ==
sizeof(EncodingB) };
187
188
189
190
191
192
193
194
195 template <
typename SourceEncoding,
typename DestEncoding>
196 static FORCEINLINE DestEncoding*
Convert(DestEncoding* Dest, int32 DestSize,
const SourceEncoding* Src)
281
282
283
284
285
286
287
288
289
290
291 template <
typename SourceEncoding,
typename DestEncoding>
292 static FORCEINLINE DestEncoding*
Convert(DestEncoding* Dest, int32 DestSize,
const SourceEncoding* Src, int32 SrcSize)
348
349
350
351
352
353
354 template <
typename DestEncoding,
typename SourceEncoding>
374
375
376
377
378
379
380
381 template <
typename DestEncoding,
typename SourceEncoding>
394 static int32
Strncmp(
const ANSICHAR* String1,
const ANSICHAR* String2, SIZE_T Count);
395 static int32
Strncmp(
const WIDECHAR* String1,
const ANSICHAR* String2, SIZE_T Count);
396 static int32
Strncmp(
const UTF8CHAR* String1,
const ANSICHAR* String2, SIZE_T Count);
397 static int32
Strncmp(
const ANSICHAR* String1,
const WIDECHAR* String2, SIZE_T Count);
398 static int32
Strncmp(
const WIDECHAR* String1,
const WIDECHAR* String2, SIZE_T Count);
399 static int32
Strncmp(
const UTF8CHAR* String1,
const WIDECHAR* String2, SIZE_T Count);
400 static int32
Strncmp(
const ANSICHAR* String1,
const UTF8CHAR* String2, SIZE_T Count);
401 static int32
Strncmp(
const WIDECHAR* String1,
const UTF8CHAR* String2, SIZE_T Count);
402 static int32
Strncmp(
const UTF8CHAR* String1,
const UTF8CHAR* String2, SIZE_T Count);
406
407
408
409
410
411
412
413 static void*
Memcpy(
void* Dest,
const void* Src, SIZE_T Count);
417
418
419
420
421 template <
typename DestEncoding,
typename SourceEncoding>
426
427
428
429
430
431 template <
typename DestEncoding,
typename SourceEncoding>
#define checkfSlow(expr, format,...)
#define UE_PTRDIFF_TO_INT32(argument)
#define UE_DEPRECATED(Version, Message)
ARK_API UTF8CHAR * Convert(UTF8CHAR *Dest, int32 DestLen, const UTF32CHAR *Src, int32 SrcLen)
ARK_API int32 GetConvertedLength(const UTF8CHAR *, const UTF32CHAR *Source, int32 SourceLen)
ARK_API UTF8CHAR * Convert(UTF8CHAR *Dest, int32 DestLen, const WIDECHAR *Src)
ARK_API int32 GetConvertedLength(const WIDECHAR *, const UTF8CHAR *Source)
static FORCEINLINE bool IsEncodedSurrogate(const uint32 Codepoint)
ARK_API ANSICHAR * Convert(ANSICHAR *Dest, int32 DestLen, const UTF8CHAR *Src, int32 SrcLen)
ARK_API int32 GetConvertedLength(const UTF8CHAR *, const UCS2CHAR *Source)
ARK_API WIDECHAR * Convert(WIDECHAR *Dest, int32 DestLen, const UTF8CHAR *Src)
ARK_API int32 GetConvertedLength(const UTF8CHAR *, const UTF32CHAR *Source)
static FORCEINLINE bool IsHighSurrogate(const uint32 Codepoint)
ARK_API UTF8CHAR * Convert(UTF8CHAR *Dest, int32 DestLen, const WIDECHAR *Src, int32 SrcLen)
ARK_API int32 GetConvertedLength(const UCS2CHAR *, const UTF8CHAR *Source)
static int32 ConvertFromUTF8(DestBufferType &ConvertedBuffer, int32 DestLen, const UTF8CHAR *Source, SourceEndType SourceEnd)
ARK_API int32 GetConvertedLength(const UTF8CHAR *, const UCS2CHAR *Source, int32 SourceLen)
ARK_API UCS2CHAR * Convert(UCS2CHAR *Dest, int32 DestLen, const UTF8CHAR *Src, int32 SrcLen)
ARK_API int32 GetConvertedLength(const ANSICHAR *, const UTF8CHAR *Source)
static FORCEINLINE bool IsLowSurrogate(const uint32 Codepoint)
static bool ReadTrailingOctet(uint32 &OutOctet, const UTF8CHAR *&Ptr, SourceEndType &SourceEnd)
ARK_API int32 GetConvertedLength(const UTF8CHAR *, const WIDECHAR *Source, int32 SourceLen)
void PopFront(Pointer &Ptr, int32 &Len)
ARK_API int32 GetConvertedLength(const UCS2CHAR *, const UTF8CHAR *Source, int32 SourceLen)
FORCEINLINE bool IsValidCodepoint(const uint32 Codepoint)
ARK_API WIDECHAR * Convert(WIDECHAR *Dest, int32 DestLen, const UTF8CHAR *Src, int32 SrcLen)
bool IsRangeEmpty(Pointer &Ptr, FNullTerminal)
ARK_API ANSICHAR * Convert(ANSICHAR *Dest, int32 DestLen, const UTF8CHAR *Src)
static FORCEINLINE bool IsSurrogate(const uint32 Codepoint)
bool IsRangeEmpty(Pointer &Ptr, int32 &Len)
ARK_API UTF8CHAR * Convert(UTF8CHAR *Dest, int32 DestLen, const UCS2CHAR *Src)
ARK_API int32 GetConvertedLength(const WIDECHAR *, const UTF8CHAR *Source, int32 SourceLen)
ARK_API UCS2CHAR * Convert(UCS2CHAR *Dest, int32 DestLen, const UTF8CHAR *Src)
ARK_API UTF8CHAR * Convert(UTF8CHAR *Dest, int32 DestLen, const UTF32CHAR *Src)
static FORCEINLINE void DecodeSurrogate(const uint32 Codepoint, uint16 &OutHighSurrogate, uint16 &OutLowSurrogate)
static bool WriteCodepointToBuffer(uint32 Codepoint, BufferType &OutputIterator, int32 &OutputIteratorByteSizeRemaining)
static uint32 CodepointFromUtf8(const UTF8CHAR *&SourceString, SourceEndType &SourceEnd)
void PopFront(Pointer &Ptr, FNullTerminal)
ARK_API UTF8CHAR * Convert(UTF8CHAR *Dest, int32 DestLen, const UCS2CHAR *Src, int32 SrcLen)
ARK_API int32 GetConvertedLength(const UTF8CHAR *, const WIDECHAR *Source)
static FORCEINLINE uint32 EncodeSurrogate(const uint16 HighSurrogate, const uint16 LowSurrogate)
void LogBogusCharsImpl(const SourceEncoding *Src, SourceEndType SourceEnd)
ARK_API int32 GetConvertedLength(const ANSICHAR *, const UTF8CHAR *Source, int32 SourceLen)
static int32 ConvertToUTF8(DestBufferType &Dest, int32 DestLen, const FromType *Source, SourceEndType SourceEnd)
static FORCEINLINE void * Memcpy(void *Dest, const void *Src, SIZE_T Count)
friend int32 operator-(TCountingOutputIterator Lhs, TCountingOutputIterator Rhs)
TCountingOutputIterator()
const DestType & operator=(const DestType &Val) const
const TCountingOutputIterator & operator+=(const int32 Amount)
const TCountingOutputIterator & operator++()
const TCountingOutputIterator & operator*() const
const TCountingOutputIterator & operator++(int)