3#include "GenericPlatform/GenericPlatformString.h"
4#include "HAL/UnrealMemory.h"
6#include "Containers/UnrealString.h"
17template <>
const TCHAR* FGenericPlatformString::GetEncodingTypeName<
wchar_t>() {
return TEXT(
"WCHAR_T"); }
38
39
40 template <
typename DestType>
53 const DestType&
operator=(
const DestType& Val)
const
72 if ((Codepoint > 0x10FFFF) ||
73 (Codepoint == 0xFFFE) || (Codepoint == 0xFFFF))
83 return (Codepoint & 0xFFFFF800) == 0xD800;
89 return (Codepoint & 0xFFFFFC00) == 0xD800;
95 return (Codepoint & 0xFFFFFC00) == 0xDC00;
105 const uint32 TmpCodepoint = Codepoint - 0x10000;
117
118
119
120
121
122
123
124 template <
typename BufferType>
197 template <
typename Pointer>
203 template <
typename Pointer>
209 template <
typename Pointer>
212 checkfSlow(
Len > 0, TEXT(
"Trying to pop past end end of the range"));
217 template <
typename Pointer>
220 checkfSlow(*
Ptr !=
'\0', TEXT(
"Trying to pop the null terminator of the string"));
224 template <
typename DestBufferType,
typename FromType,
typename SourceEndType>
225 static int32
ConvertToUTF8(DestBufferType& Dest, int32 DestLen,
const FromType* Source, SourceEndType SourceEnd)
229 if constexpr (
sizeof(
FromType) == 4)
300 template <
typename SourceEndType>
313 if ((
Octet & 192) != 128)
322 template <
typename SourceEndType>
390 Octet -= (128+64+32+16);
430
431
432 template <
typename DestType,
typename DestBufferType,
typename SourceEndType>
433 static int32
ConvertFromUTF8(DestBufferType& ConvertedBuffer, int32 DestLen,
const UTF8CHAR* Source, SourceEndType SourceEnd)
482 if constexpr (
sizeof(
DestType) != 4)
528
529
530
531
535 int32 Result = ConvertToUTF8(Dest, INT32_MAX, Source, FNullTerminal{});
541 int32 Result = ConvertToUTF8(Dest, INT32_MAX, Source, SourceLen);
547 int32 Result = ConvertToUTF8(Dest, INT32_MAX, Source, FNullTerminal{});
553 int32 Result = ConvertToUTF8(Dest, INT32_MAX, Source, SourceLen);
559 int32 Result = ConvertToUTF8(Dest, INT32_MAX, Source, FNullTerminal{});
565 int32 Result = ConvertToUTF8(Dest, INT32_MAX, Source, SourceLen);
571 int32 Result = ConvertFromUTF8<ANSICHAR>(Dest, INT32_MAX, Source, FNullTerminal{});
577 int32 Result = ConvertFromUTF8<ANSICHAR>(Dest, INT32_MAX, Source, SourceLen);
583 int32 Result = ConvertFromUTF8<WIDECHAR>(Dest, INT32_MAX, Source, FNullTerminal{});
589 int32 Result = ConvertFromUTF8<WIDECHAR>(Dest, INT32_MAX, Source, SourceLen);
595 int32 Result = ConvertFromUTF8<UCS2CHAR>(Dest, INT32_MAX, Source, FNullTerminal{});
601 int32 Result = ConvertFromUTF8<UCS2CHAR>(Dest, INT32_MAX, Source, SourceLen);
613 ARK_API UTF8CHAR*
Convert(UTF8CHAR* Dest, int32 DestLen,
const WIDECHAR* Src, int32 SrcLen)
615 if (ConvertToUTF8(Dest, DestLen, Src, SrcLen) == -1)
631 if (ConvertToUTF8(Dest, DestLen, Src, SrcLen) == -1)
647 if (ConvertToUTF8(Dest, DestLen, Src, SrcLen) == -1)
655 if (ConvertFromUTF8<ANSICHAR>(Dest, DestLen, Src,
FNullTerminal{}) == -1)
661 ARK_API ANSICHAR*
Convert(ANSICHAR* Dest, int32 DestLen,
const UTF8CHAR* Src, int32 SrcLen)
663 if (ConvertFromUTF8<ANSICHAR>(Dest, DestLen, Src, SrcLen) == -1)
671 if (ConvertFromUTF8<WIDECHAR>(Dest, DestLen, Src,
FNullTerminal{}) == -1)
677 ARK_API WIDECHAR*
Convert(WIDECHAR* Dest, int32 DestLen,
const UTF8CHAR* Src, int32 SrcLen)
679 if (ConvertFromUTF8<WIDECHAR>(Dest, DestLen, Src, SrcLen) == -1)
695 if (ConvertFromUTF8<
UCS2CHAR>(Dest, DestLen, Src, SrcLen) == -1)
702 template <
typename DestEncoding,
typename SourceEncoding,
typename SourceEndType>
747
748
749
750
751
752
753
754
755
756
760template<
typename CharType1,
typename CharType2>
761int32
StrncmpImpl(
const CharType1* String1,
const CharType2* String2, SIZE_T Count)
794template void FGenericPlatformString::LogBogusChars<ANSICHAR, WIDECHAR>(
const WIDECHAR* Src);
795template void FGenericPlatformString::LogBogusChars<ANSICHAR, WIDECHAR>(
const WIDECHAR* Src, int32 SrcSize);
796template void FGenericPlatformString::LogBogusChars<ANSICHAR, UCS2CHAR>(
const UCS2CHAR* Src);
797template void FGenericPlatformString::LogBogusChars<ANSICHAR, UCS2CHAR>(
const UCS2CHAR* Src, int32 SrcSize);
798template void FGenericPlatformString::LogBogusChars<WIDECHAR, ANSICHAR>(
const ANSICHAR* Src);
799template void FGenericPlatformString::LogBogusChars<WIDECHAR, ANSICHAR>(
const ANSICHAR* Src, int32 SrcSize);
800template void FGenericPlatformString::LogBogusChars<WIDECHAR, UCS2CHAR>(
const UCS2CHAR* Src);
801template void FGenericPlatformString::LogBogusChars<WIDECHAR, UCS2CHAR>(
const UCS2CHAR* Src, int32 SrcSize);
802template void FGenericPlatformString::LogBogusChars<UCS2CHAR, ANSICHAR>(
const ANSICHAR* Src);
803template void FGenericPlatformString::LogBogusChars<UCS2CHAR, ANSICHAR>(
const ANSICHAR* Src, int32 SrcSize);
804template void FGenericPlatformString::LogBogusChars<UCS2CHAR, WIDECHAR>(
const WIDECHAR* Src);
805template void FGenericPlatformString::LogBogusChars<UCS2CHAR, WIDECHAR>(
const WIDECHAR* Src, int32 SrcSize);
806template void FGenericPlatformString::LogBogusChars<UTF8CHAR, ANSICHAR>(
const ANSICHAR* Src);
807template void FGenericPlatformString::LogBogusChars<UTF8CHAR, ANSICHAR>(
const ANSICHAR* Src, int32 SrcSize);
808template void FGenericPlatformString::LogBogusChars<UTF8CHAR, WIDECHAR>(
const WIDECHAR* Src);
809template void FGenericPlatformString::LogBogusChars<UTF8CHAR, WIDECHAR>(
const WIDECHAR* Src, int32 SrcSize);
810template void FGenericPlatformString::LogBogusChars<UTF8CHAR, UCS2CHAR>(
const UCS2CHAR* Src);
811template void FGenericPlatformString::LogBogusChars<UTF8CHAR, UCS2CHAR>(
const UCS2CHAR* Src, int32 SrcSize);
813template void FGenericPlatformString::LogBogusChars<
wchar_t,
char16_t>(
const char16_t* Src);
814template void FGenericPlatformString::LogBogusChars<
wchar_t,
char16_t>(
const char16_t* Src, int32 SrcSize);
815template void FGenericPlatformString::LogBogusChars<
char16_t,
wchar_t>(
const wchar_t* Src);
816template void FGenericPlatformString::LogBogusChars<
char16_t,
wchar_t>(
const wchar_t* Src, int32 SrcSize);
#define checkfSlow(expr, format,...)
#define UE_PTRDIFF_TO_INT32(argument)
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)