From 6f4edf10d823164a9b5ed6c597c44514638f539a Mon Sep 17 00:00:00 2001 From: Rob Parolin Date: Wed, 10 Jul 2019 15:02:07 -0700 Subject: [PATCH] 1.26.03 --- include/EAStdC/EACType.h | 66 ++- include/EAStdC/EADateTime.h | 2 +- include/EAStdC/EAHashString.h | 10 +- include/EAStdC/EAMemory.h | 52 +-- include/EAStdC/EAProcess.h | 18 +- include/EAStdC/EAScanf.h | 24 +- include/EAStdC/EASprintf.h | 41 +- include/EAStdC/EASprintfOrdered.h | 22 +- include/EAStdC/EAString.h | 327 ++++++++------- include/EAStdC/EATextUtil.h | 53 +-- include/EAStdC/internal/Config.h | 27 +- include/EAStdC/internal/EAMemory.inl | 28 +- include/EAStdC/internal/ScanfCore.h | 16 +- include/EAStdC/internal/SprintfCore.h | 22 +- source/EADateTime.cpp | 2 +- source/EAHashString.cpp | 18 +- source/EAMemory.cpp | 14 +- source/EAProcess.cpp | 94 ++--- source/EAScanf.cpp | 18 +- source/EAScanfCore.cpp | 52 +-- source/EASprintf.cpp | 84 +--- source/EASprintfCore.cpp | 42 +- source/EASprintfOrdered.cpp | 40 +- source/EAStopwatch.cpp | 2 +- source/EAString.cpp | 574 +++++++++++++------------- source/EATextUtil.cpp | 110 ++--- test/source/TestCType.cpp | 91 ++-- test/source/TestDateTime.cpp | 22 +- test/source/TestHash.cpp | 8 +- test/source/TestMemory.cpp | 59 ++- test/source/TestProcess.cpp | 30 +- test/source/TestScanf.cpp | 52 +-- test/source/TestSprintf.cpp | 250 +++++------ test/source/TestString.cpp | 564 ++++++++++++------------- test/source/TestTextUtil.cpp | 170 ++++---- 35 files changed, 1446 insertions(+), 1558 deletions(-) diff --git a/include/EAStdC/EACType.h b/include/EAStdC/EACType.h index b998dab..6bb723f 100644 --- a/include/EAStdC/EACType.h +++ b/include/EAStdC/EACType.h @@ -38,108 +38,104 @@ #include -#ifndef EA_WCHAR_UNIQUE -#define EA_WCHAR_UNIQUE 0 -#endif - namespace EA { namespace StdC { - EASTDC_API int Isalnum(char8_t c); + EASTDC_API int Isalnum(char c); EASTDC_API int Isalnum(char16_t c); EASTDC_API int Isalnum(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Isalnum(wchar_t c); #endif - EASTDC_API int Isalpha(char8_t c); + EASTDC_API int Isalpha(char c); EASTDC_API int Isalpha(char16_t c); EASTDC_API int Isalpha(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Isalpha(wchar_t c); #endif - EASTDC_API int Isdigit(char8_t c); + EASTDC_API int Isdigit(char c); EASTDC_API int Isdigit(char16_t c); EASTDC_API int Isdigit(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Isdigit(wchar_t c); #endif - EASTDC_API int Isxdigit(char8_t c); + EASTDC_API int Isxdigit(char c); EASTDC_API int Isxdigit(char16_t c); EASTDC_API int Isxdigit(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Isxdigit(wchar_t c); #endif - EASTDC_API int Isgraph(char8_t c); + EASTDC_API int Isgraph(char c); EASTDC_API int Isgraph(char16_t c); EASTDC_API int Isgraph(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Isgraph(wchar_t c); #endif - EASTDC_API int Islower(char8_t c); + EASTDC_API int Islower(char c); EASTDC_API int Islower(char16_t c); EASTDC_API int Islower(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Islower(wchar_t c); #endif - EASTDC_API char8_t Tolower(char8_t c); + EASTDC_API char Tolower(char c); EASTDC_API char16_t Tolower(char16_t c); EASTDC_API char32_t Tolower(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API wchar_t Tolower(wchar_t c); #endif - EASTDC_API int Isupper(char8_t c); + EASTDC_API int Isupper(char c); EASTDC_API int Isupper(char16_t c); EASTDC_API int Isupper(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Isupper(wchar_t c); #endif - EASTDC_API char8_t Toupper(char8_t c); + EASTDC_API char Toupper(char c); EASTDC_API char16_t Toupper(char16_t c); EASTDC_API char32_t Toupper(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API wchar_t Toupper(wchar_t c); #endif - EASTDC_API int Isprint(char8_t c); + EASTDC_API int Isprint(char c); EASTDC_API int Isprint(char16_t c); EASTDC_API int Isprint(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Isprint(wchar_t c); #endif - EASTDC_API int Ispunct(char8_t c); + EASTDC_API int Ispunct(char c); EASTDC_API int Ispunct(char16_t c); EASTDC_API int Ispunct(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Ispunct(wchar_t c); #endif - EASTDC_API int Isspace(char8_t c); + EASTDC_API int Isspace(char c); EASTDC_API int Isspace(char16_t c); EASTDC_API int Isspace(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Isspace(wchar_t c); #endif - EASTDC_API int Iscntrl(char8_t c); + EASTDC_API int Iscntrl(char c); EASTDC_API int Iscntrl(char16_t c); EASTDC_API int Iscntrl(char32_t c); #if EA_WCHAR_UNIQUE EASTDC_API int Iscntrl(wchar_t c); #endif - EASTDC_API int Isascii(char8_t c); + EASTDC_API int Isascii(char c); EASTDC_API int Isascii(char16_t c); EASTDC_API int Isascii(char32_t c); #if EA_WCHAR_UNIQUE @@ -183,7 +179,7 @@ namespace StdC - inline int Isalnum(char8_t c) // char8_t is the same as char -- it is a signed or unsigned 8 bit value + inline int Isalnum(char c) // char is the same as char -- it is a signed or unsigned 8 bit value { return EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_ALNUM; } @@ -207,7 +203,7 @@ namespace StdC - inline int Isalpha(char8_t c) + inline int Isalpha(char c) { return EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_ALPHA; } @@ -230,7 +226,7 @@ namespace StdC #endif - inline int Isdigit(char8_t c) + inline int Isdigit(char c) { return EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_DIGIT; @@ -263,7 +259,7 @@ namespace StdC - inline int Isxdigit(char8_t c) + inline int Isxdigit(char c) { return EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_XDIGIT; } @@ -287,7 +283,7 @@ namespace StdC - inline int Isgraph(char8_t c) + inline int Isgraph(char c) { return EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_GRAPH; } @@ -310,7 +306,7 @@ namespace StdC #endif - inline int Islower(char8_t c) + inline int Islower(char c) { return EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_LOWER; } @@ -334,9 +330,9 @@ namespace StdC - inline char8_t Tolower(char8_t c) + inline char Tolower(char c) { - return (char8_t)EASTDC_WLOWER_MAP[(uint8_t)c]; + return (char)EASTDC_WLOWER_MAP[(uint8_t)c]; } inline char16_t Tolower(char16_t c) @@ -357,9 +353,9 @@ namespace StdC #endif - inline int Isupper(char8_t c) + inline int Isupper(char c) { - return (char8_t)EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_UPPER; + return (char)EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_UPPER; } inline int Isupper(char16_t c) @@ -380,9 +376,9 @@ namespace StdC #endif - inline char8_t Toupper(char8_t c) + inline char Toupper(char c) { - return (char8_t)EASTDC_WUPPER_MAP[(uint8_t)c]; + return (char)EASTDC_WUPPER_MAP[(uint8_t)c]; } inline char16_t Toupper(char16_t c) @@ -403,7 +399,7 @@ namespace StdC #endif - inline int Isprint(char8_t c) + inline int Isprint(char c) { return EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_PRINT; } @@ -426,7 +422,7 @@ namespace StdC #endif - inline int Ispunct(char8_t c) + inline int Ispunct(char c) { return EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_PUNCT; } @@ -449,7 +445,7 @@ namespace StdC #endif - inline int Isspace(char8_t c) + inline int Isspace(char c) { return EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_SPACE; } @@ -472,7 +468,7 @@ namespace StdC #endif - inline int Iscntrl(char8_t c) + inline int Iscntrl(char c) { return EASTDC_WCTYPE_MAP[(uint8_t)c] & EASTDC_WCTYPE_CONTROL; } @@ -495,7 +491,7 @@ namespace StdC #endif - inline int Isascii(char8_t c) + inline int Isascii(char c) { return (uint8_t)c < 0x80; } diff --git a/include/EAStdC/EADateTime.h b/include/EAStdC/EADateTime.h index 94cd639..acd3e84 100644 --- a/include/EAStdC/EADateTime.h +++ b/include/EAStdC/EADateTime.h @@ -572,7 +572,7 @@ namespace StdC /// The returned string isn't guaranteed to match equivalent results from other platforms. /// The return value will be false in the case that EASTDC_UTC_TIME_AVAILABLE == 0. enum { kTimeZoneNameCapacity = 64 }; - EASTDC_API bool GetTimeZoneName(char8_t* pName, bool bDaylightSavingsName); + EASTDC_API bool GetTimeZoneName(char* pName, bool bDaylightSavingsName); /// DateTimeToTm /// Converts a DateTime to a C tm struct. diff --git a/include/EAStdC/EAHashString.h b/include/EAStdC/EAHashString.h index 84b23f7..f54f995 100644 --- a/include/EAStdC/EAHashString.h +++ b/include/EAStdC/EAHashString.h @@ -5,11 +5,11 @@ ///////////////////////////////////////////////////////////////////////////// // Defines the following: // uint32_t FNV1 (const void* pData, size_t nLength, uint32_t nInitialValue = kFNV1InitialValue); -// uint32_t FNV1_String8 (const char8_t* pData, uint32_t nInitialValue = kFNV1InitialValue, CharCase charCase = kCharCaseAny); +// uint32_t FNV1_String8 (const char* pData, uint32_t nInitialValue = kFNV1InitialValue, CharCase charCase = kCharCaseAny); // uint32_t FNV1_String16(const char16_t* pData, uint32_t nInitialValue = kFNV1InitialValue, CharCase charCase = kCharCaseAny); // // uint64_t FNV64 (const void* pData, size_t nLength, uint64_t nInitialValue = kFNV1InitialValue); -// uint64_t FNV64_String8 (const char8_t* pData, uint64_t nInitialValue = kFNV1InitialValue, CharCase charCase = kCharCaseAny); +// uint64_t FNV64_String8 (const char* pData, uint64_t nInitialValue = kFNV1InitialValue, CharCase charCase = kCharCaseAny); // uint64_t FNV64_String16(const char16_t* pData, uint64_t nInitialValue = kFNV1InitialValue, CharCase charCase = kCharCaseAny); // // template<> class CTStringHash; @@ -78,7 +78,7 @@ namespace StdC const uint32_t kFNV1InitialValue = 2166136261U; EASTDC_API uint32_t FNV1 (const void* pData, size_t nLength, uint32_t nInitialValue = kFNV1InitialValue); - EASTDC_API uint32_t FNV1_String8 (const char8_t* pData, uint32_t nInitialValue = kFNV1InitialValue, CharCase charCase = kCharCaseAny); + EASTDC_API uint32_t FNV1_String8 (const char* pData, uint32_t nInitialValue = kFNV1InitialValue, CharCase charCase = kCharCaseAny); EASTDC_API uint32_t FNV1_String16(const char16_t* pData, uint32_t nInitialValue = kFNV1InitialValue, CharCase charCase = kCharCaseAny); EASTDC_API uint32_t FNV1_String32(const char32_t* pData, uint32_t nInitialValue = kFNV1InitialValue, CharCase charCase = kCharCaseAny); @@ -88,7 +88,7 @@ namespace StdC const uint64_t kFNV64InitialValue = UINT64_C(14695981039346656037); EASTDC_API uint64_t FNV64 (const void* pData, size_t nLength, uint64_t nInitialValue = kFNV64InitialValue); - EASTDC_API uint64_t FNV64_String8 (const char8_t* pData, uint64_t nInitialValue = kFNV64InitialValue, CharCase charCase = kCharCaseAny); + EASTDC_API uint64_t FNV64_String8 (const char* pData, uint64_t nInitialValue = kFNV64InitialValue, CharCase charCase = kCharCaseAny); EASTDC_API uint64_t FNV64_String16(const char16_t* pData, uint64_t nInitialValue = kFNV64InitialValue, CharCase charCase = kCharCaseAny); EASTDC_API uint64_t FNV64_String32(const char32_t* pData, uint64_t nInitialValue = kFNV64InitialValue, CharCase charCase = kCharCaseAny); @@ -98,7 +98,7 @@ namespace StdC const uint32_t kDJB2InitialValue = 5381; EASTDC_API uint32_t DJB2 (const void* pData, size_t nLength, uint32_t nInitialValue = kDJB2InitialValue); - EASTDC_API uint32_t DJB2_String8 (const char8_t* pData, uint32_t nInitialValue = kDJB2InitialValue, CharCase charCase = kCharCaseAny); + EASTDC_API uint32_t DJB2_String8 (const char* pData, uint32_t nInitialValue = kDJB2InitialValue, CharCase charCase = kCharCaseAny); EASTDC_API uint32_t DJB2_String16(const char16_t* pData, uint32_t nInitialValue = kDJB2InitialValue, CharCase charCase = kCharCaseAny); diff --git a/include/EAStdC/EAMemory.h b/include/EAStdC/EAMemory.h index 27c76c9..8286c78 100644 --- a/include/EAStdC/EAMemory.h +++ b/include/EAStdC/EAMemory.h @@ -17,15 +17,15 @@ // work on this kind of memory and you can instead use the regular functions // such as Memcpy for uncacheable memory. // -// char8_t* Memcpy (void* pDestination, const void* pSource, size_t n); -// char8_t* MemcpyC (void* pDestination, const void* pSource, size_t n); // Faster version for cacheable memory (and not video memory). -// char8_t* MemcpyS (void* pDestination, const void* pSource, size_t n); // Streaming memory copy, doesn't invalidate the cache. -// char8_t* Memcpy128 (void* pDestination, const void* pSource, size_t n); -// char8_t* Memcpy128C (void* pDestination, const void* pSource, size_t n); // Faster version for cacheable memory (and not video memory). -// char8_t* Memmove (void* pDestination, const void* pSource, size_t n); -// char8_t* MemmoveC (void* pDestination, const void* pSource, size_t n); // Faster version for cacheable memory (and not video memory). +// char* Memcpy (void* pDestination, const void* pSource, size_t n); +// char* MemcpyC (void* pDestination, const void* pSource, size_t n); // Faster version for cacheable memory (and not video memory). +// char* MemcpyS (void* pDestination, const void* pSource, size_t n); // Streaming memory copy, doesn't invalidate the cache. +// char* Memcpy128 (void* pDestination, const void* pSource, size_t n); +// char* Memcpy128C (void* pDestination, const void* pSource, size_t n); // Faster version for cacheable memory (and not video memory). +// char* Memmove (void* pDestination, const void* pSource, size_t n); +// char* MemmoveC (void* pDestination, const void* pSource, size_t n); // Faster version for cacheable memory (and not video memory). // -// const void* Memchr(const void* p, char8_t c, size_t n); +// const void* Memchr(const void* p, char c, size_t n); // int Memcmp(const void* p1, const void* p2, size_t n); // void* Memmem(const void* pMemory, size_t memorySize, const void* pFind, size_t findSize); // @@ -347,14 +347,14 @@ namespace StdC /// must be writable. /// Works with uncacheable memory, such as video memory. /// - EASTDC_API char8_t* Memcpy(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount); + EASTDC_API char* Memcpy(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount); // Cacheable memory copy // Works only with cacheable memory (i.e. conventional system memory). // The source and destination memory must not overlap. // Cannot be relied on to work with uncachable memory, such as video memory. // There are no alignment restrictions on either pDestination or pSource. - EASTDC_API char8_t* MemcpyC(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount); + EASTDC_API char* MemcpyC(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount); // Streaming memcpy // This function copies memory from source to destination without filling the cache with the memory. @@ -363,7 +363,7 @@ namespace StdC // Works on both cacheable and uncacheable memory. // The source and destination memory must not overlap. // There are no alignment restrictions on either pDestination or pSource. - EASTDC_API char8_t* MemcpyS(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount); + EASTDC_API char* MemcpyS(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount); /////////////////////////////////////////////////////////////////////////// @@ -379,14 +379,14 @@ namespace StdC /// that allocated with VirtualAlloc(..., PAGE_NOCACHE) or VirtualAlloc(..., PAGE_WRITECOMBINE). /// In fact, on XBox 360 this function is the same as XMemCpy128. /// - EASTDC_API char8_t* Memcpy128(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount); + EASTDC_API char* Memcpy128(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount); // cacheable 128 byte memcpy // This function is useful for higher performance memory copies when the requirements can be met. // The address pointed to by pDestination must be aligned on a 128-byte boundary, and uint8Count must be a multiple of 128. // Works only with cacheable memory (i.e. conventional system memory). // The source and destination memory must not overlap. - EASTDC_API char8_t* Memcpy128C(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount); + EASTDC_API char* Memcpy128C(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount); /////////////////////////////////////////////////////////////////////////// @@ -400,13 +400,13 @@ namespace StdC /// must be writable. /// Works with uncacheable memory, such as video memory. /// - EASTDC_API char8_t* Memmove(void* pDestination, const void* pSource, size_t nByteCount); + EASTDC_API char* Memmove(void* pDestination, const void* pSource, size_t nByteCount); // Cacheable memory move // Works only with cacheable memory (i.e. conventional system memory). // The source and destination memory may overlap. // Cannot be relied on to work with uncachable memory, such as video memory. - EASTDC_API char8_t* MemmoveC(void* pDestination, const void* pSource, size_t nByteCount); + EASTDC_API char* MemmoveC(void* pDestination, const void* pSource, size_t nByteCount); /////////////////////////////////////////////////////////////////////////// @@ -419,7 +419,7 @@ namespace StdC /// There are no restrictions about the type of memory p refers /// to except that it be readable. /// - EASTDC_API const char8_t* Memchr (const char8_t* p, char8_t c, size_t n); + EASTDC_API const char* Memchr (const char* p, char c, size_t n); EASTDC_API const char16_t* Memchr16(const char16_t* p, char16_t c, size_t n); EASTDC_API const char32_t* Memchr32(const char32_t* p, char32_t c, size_t n); #if EA_WCHAR_UNIQUE @@ -576,26 +576,6 @@ namespace StdC EASTDC_API void MemFillSpecific(void* pDestination, const void* pSource, unsigned int destByteCount, unsigned int sourceByteCount); - /////////////////////////////////////////////////////////////////////////// - /// rwstdc compatibility - /// - /// Deprecated functions. - /// - #if EASTDC_MEMCHR16_ENABLED - // This function is deprecated and replaced by Memchr16, as it collides with the Standard C memchr - // function which takes a void* argument. - EA_PREFIX_DEPRECATED EASTDC_API const char16_t* Memchr(const char16_t* pString, char16_t c, size_t nCharCount); - #endif - - #if EASTDC_MEMCPY16_ENABLED - // These function are deprecated. It was mistakenly created during a code migration. - // It is scheduled for removal in a future version of this package. - EA_PREFIX_DEPRECATED EASTDC_API char16_t* Memcpy(char16_t* pDestination, const char16_t* pSource, size_t nCharCount) EA_POSTFIX_DEPRECATED; - EA_PREFIX_DEPRECATED EASTDC_API char16_t* Memmove(char16_t* pDestination, const char16_t* pSource, size_t nCharCount) EA_POSTFIX_DEPRECATED; - EA_PREFIX_DEPRECATED EASTDC_API int Memcmp(const char16_t* pString1, const char16_t* pString2, size_t nCharCount) EA_POSTFIX_DEPRECATED; - #endif - - /// StaticMemory /// /// Allows you to declare memory that's sized and aligned appropriately and diff --git a/include/EAStdC/EAProcess.h b/include/EAStdC/EAProcess.h index fc3ea52..8682f15 100644 --- a/include/EAStdC/EAProcess.h +++ b/include/EAStdC/EAProcess.h @@ -72,7 +72,7 @@ namespace EA /// GetCurrentProcessPath(path, IO::kMaxPathLength); /// printf("Path: %ls\n", path); /// - EASTDC_API size_t GetCurrentProcessPath(char8_t* pPath, int pathCapacity = kMaxPathLength, int pathFlags = kPathFlagNone); + EASTDC_API size_t GetCurrentProcessPath(char* pPath, int pathCapacity = kMaxPathLength, int pathFlags = kPathFlagNone); EASTDC_API size_t GetCurrentProcessPath(char16_t* pPath, int pathCapacity = kMaxPathLength, int pathFlags = kPathFlagNone); EASTDC_API size_t GetCurrentProcessPath(char32_t* pPath, int pathCapacity = kMaxPathLength, int pathFlags = kPathFlagNone); #if defined(EA_WCHAR_UNIQUE) && EA_WCHAR_UNIQUE @@ -86,7 +86,7 @@ namespace EA /// to know it without being told. Subsequent calls to GetCurrentProcessPath with flags other /// than kPathFlagNone will ignore such flags and simply return this path. /// - EASTDC_API void SetCurrentProcessPath(const char8_t* pPath); + EASTDC_API void SetCurrentProcessPath(const char* pPath); /// GetCurrentProcessDirectory @@ -108,7 +108,7 @@ namespace EA /// GetCurrentProcessDirectory(dir, IO::kMaxDirectoryLength); /// printf("Directory: %ls\n", dir); /// - EASTDC_API size_t GetCurrentProcessDirectory(char8_t* pDirectory, int pathCapacity = kMaxDirectoryLength, int pathFlags = kPathFlagNone); + EASTDC_API size_t GetCurrentProcessDirectory(char* pDirectory, int pathCapacity = kMaxDirectoryLength, int pathFlags = kPathFlagNone); EASTDC_API size_t GetCurrentProcessDirectory(char16_t* pDirectory, int pathCapacity = kMaxDirectoryLength, int pathFlags = kPathFlagNone); EASTDC_API size_t GetCurrentProcessDirectory(char32_t* pDirectory, int pathCapacity = kMaxDirectoryLength, int pathFlags = kPathFlagNone); #if defined(EA_WCHAR_UNIQUE) && EA_WCHAR_UNIQUE @@ -143,7 +143,7 @@ namespace EA /// if(GetEnvironmentVar(L"UserName", pValue, 64) < 64) /// printf("Path: %ls\n", pValue); /// - EASTDC_API size_t GetEnvironmentVar(const char8_t* pName, char8_t* pValue, size_t valueCapacity); + EASTDC_API size_t GetEnvironmentVar(const char* pName, char* pValue, size_t valueCapacity); EASTDC_API size_t GetEnvironmentVar(const char16_t* pName, char16_t* pValue, size_t valueCapacity); EASTDC_API size_t GetEnvironmentVar(const char32_t* pName, char32_t* pValue, size_t valueCapacity); #if defined(EA_WCHAR_UNIQUE) && EA_WCHAR_UNIQUE @@ -165,7 +165,7 @@ namespace EA /// if(SetEnvironmentVar("User Name", "Lance Armstrong")) /// printf("Success setting user name.\n"); /// - EASTDC_API bool SetEnvironmentVar(const char8_t* pName, const char8_t* pValue); + EASTDC_API bool SetEnvironmentVar(const char* pName, const char* pValue); EASTDC_API bool SetEnvironmentVar(const char16_t* pName, const char16_t* pValue); EASTDC_API bool SetEnvironmentVar(const char32_t* pName, const char32_t* pValue); #if defined(EA_WCHAR_UNIQUE) && EA_WCHAR_UNIQUE @@ -199,7 +199,7 @@ namespace EA /// const char16_t* ptrArray[4] = { EA_CHAR16("/System/Utilities/PingSomeAddresses.exe"), EA_CHAR16("www.bozo.com"), EA_CHAR16("www.nifty.com"), NULL }; /// int nReturnValue = Spawn("/System/Utilities/PingSomeAddresses.exe", ptrArray, true); /// - EASTDC_API int Spawn(const char8_t* pPath, const char8_t* const* pArgumentArray, bool wait = false); + EASTDC_API int Spawn(const char* pPath, const char* const* pArgumentArray, bool wait = false); EASTDC_API int Spawn(const char16_t* pPath, const char16_t* const* pArgumentArray, bool wait = false); EASTDC_API int Spawn(const char32_t* pPath, const char32_t* const* pArgumentArray, bool wait = false); #if defined(EA_WCHAR_UNIQUE) && EA_WCHAR_UNIQUE @@ -221,7 +221,7 @@ namespace EA /// /// ExecuteShellCommand("su root\nrm /* -r"); /// - EASTDC_API int ExecuteShellCommand(const char8_t* pCommand); + EASTDC_API int ExecuteShellCommand(const char* pCommand); EASTDC_API int ExecuteShellCommand(const char16_t* pCommand); EASTDC_API int ExecuteShellCommand(const char32_t* pCommand); #if defined(EA_WCHAR_UNIQUE) && EA_WCHAR_UNIQUE @@ -255,7 +255,7 @@ namespace EA /// if(SearchEnvironmentPath("perforce.exe", fullPath, "PATH")) /// printf("Full path to Perforce is "%ls\n", fullPath); /// - EASTDC_API bool SearchEnvironmentPath(const char8_t* pFileName, char8_t* pPath, const char8_t* pEnvironmentVar = NULL); + EASTDC_API bool SearchEnvironmentPath(const char* pFileName, char* pPath, const char* pEnvironmentVar = NULL); EASTDC_API bool SearchEnvironmentPath(const char16_t* pFileName, char16_t* pPath, const char16_t* pEnvironmentVar = NULL); EASTDC_API bool SearchEnvironmentPath(const char32_t* pFileName, char32_t* pPath, const char32_t* pEnvironmentVar = NULL); #if defined(EA_WCHAR_UNIQUE) && EA_WCHAR_UNIQUE @@ -277,7 +277,7 @@ namespace EA /// OpenFile("/system/settings/somefile.html"); /// OpenFile("http://www.bozo.com/somefile.html"); /// - EASTDC_API bool OpenFile(const char8_t* pPath); + EASTDC_API bool OpenFile(const char* pPath); EASTDC_API bool OpenFile(const char16_t* pPath); EASTDC_API bool OpenFile(const char32_t* pPath); #if defined(EA_WCHAR_UNIQUE) && EA_WCHAR_UNIQUE diff --git a/include/EAStdC/EAScanf.h b/include/EAStdC/EAScanf.h index f8fc5db..7bb72a4 100644 --- a/include/EAStdC/EAScanf.h +++ b/include/EAStdC/EAScanf.h @@ -100,7 +100,7 @@ namespace StdC // of ReadFunction implementations. // // UTF8 multi-byte characters should be returned as their unsigned value. - // Thus even though char8_t is signed, all characters are read and written + // Thus even though char is signed, all characters are read and written // as if they are uint8_t. The only time a negative value should be used is // in the case of a -1 return value. This situation exists because it // exists as such with the C Standard Library, for better or worse. @@ -111,7 +111,7 @@ namespace StdC // ReadFunction16 // // This function is currently identical to ReadFunction8 with the exception - // that kReadActionBegin will specify char16_t characters instead of char8_t. + // that kReadActionBegin will specify char16_t characters instead of char. // typedef int (*ReadFunction16)(ReadAction readAction, int value, void* pContext); @@ -119,7 +119,7 @@ namespace StdC // ReadFunction32 // // This function is currently identical to ReadFunction8 with the exception - // that kReadActionBegin will specify char32_t characters instead of char8_t. + // that kReadActionBegin will specify char32_t characters instead of char. // typedef int (*ReadFunction32)(ReadAction readAction, int value, void* pContext); @@ -127,7 +127,7 @@ namespace StdC // ReadFunctionW // // This function is currently identical to ReadFunction8 with the exception - // that kReadActionBegin will specify wchar_t characters instead of char8_t. + // that kReadActionBegin will specify wchar_t characters instead of char. // typedef int (*ReadFunctionW)(ReadAction readAction, int value, void* pContext); @@ -148,10 +148,10 @@ namespace StdC /////////////////////////////////////////////////////////////////////////////// /// Scanf /// - EASTDC_API int Cscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, ...); - EASTDC_API int Fscanf(FILE* pFile, const char8_t* pFormat, ...); - EASTDC_API int Scanf(const char8_t* pFormat, ...); - EASTDC_API int Sscanf(const char8_t* pTextBuffer, const char8_t* pFormat, ...); + EASTDC_API int Cscanf(ReadFunction8 pReadFunction8, void* pContext, const char* pFormat, ...); + EASTDC_API int Fscanf(FILE* pFile, const char* pFormat, ...); + EASTDC_API int Scanf(const char* pFormat, ...); + EASTDC_API int Sscanf(const char* pTextBuffer, const char* pFormat, ...); EASTDC_API int Cscanf(ReadFunction16 pReadFunction16, void* pContext, const char16_t* pFormat, ...); EASTDC_API int Fscanf(FILE* pFile, const char16_t* pFormat, ...); @@ -174,10 +174,10 @@ namespace StdC /////////////////////////////////////////////////////////////////////////////// /// Vscanf /// - EASTDC_API int Vcscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, va_list arguments); - EASTDC_API int Vfscanf(FILE* pFile, const char8_t* pFormat, va_list arguments); - EASTDC_API int Vscanf(const char8_t* pFormat, va_list arguments); - EASTDC_API int Vsscanf(const char8_t* pTextBuffer, const char8_t* pFormat, va_list arguments); + EASTDC_API int Vcscanf(ReadFunction8 pReadFunction8, void* pContext, const char* pFormat, va_list arguments); + EASTDC_API int Vfscanf(FILE* pFile, const char* pFormat, va_list arguments); + EASTDC_API int Vscanf(const char* pFormat, va_list arguments); + EASTDC_API int Vsscanf(const char* pTextBuffer, const char* pFormat, va_list arguments); EASTDC_API int Vcscanf(ReadFunction16 pReadFunction16, void* pContext, const char16_t* pFormat, va_list arguments); EASTDC_API int Vfscanf(FILE* pFile, const char16_t* pFormat, va_list arguments); diff --git a/include/EAStdC/EASprintf.h b/include/EAStdC/EASprintf.h index 51bf4c5..d469bbc 100644 --- a/include/EAStdC/EASprintf.h +++ b/include/EAStdC/EASprintf.h @@ -86,7 +86,7 @@ namespace StdC // write an optimized pathway for the case that pData is in fact 0-terminated, // which will often be the case. // - typedef int (*WriteFunction8)(const char8_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext, WriteFunctionState wfs); + typedef int (*WriteFunction8)(const char* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext, WriteFunctionState wfs); ///////////////////////////////////////////////////////////////////////////// // WriteFunction16 @@ -171,13 +171,13 @@ namespace StdC /// Vsnprintf: Print to a string, with capacity specified, same as the C vsnprintf function. /// Vdprintf: Print to a debug output destination (e.g. OutputDebugString on Microsoft platforms). /// - EASTDC_API int Vcprintf(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int Vfprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int Vprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int Vsprintf(char8_t* EA_RESTRICT pDestination, const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int Vsnprintf(char8_t* EA_RESTRICT pDestination, size_t n, const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int Vscprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int Vdprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int Vcprintf(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pContext, const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int Vfprintf(FILE* EA_RESTRICT pFile, const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int Vprintf(const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int Vsprintf(char* EA_RESTRICT pDestination, const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int Vsnprintf(char* EA_RESTRICT pDestination, size_t n, const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int Vscprintf(const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int Vdprintf(const char* EA_RESTRICT pFormat, va_list arguments); EASTDC_API int Vcprintf(WriteFunction16 pWriteFunction16, void* EA_RESTRICT pContext, const char16_t* EA_RESTRICT pFormat, va_list arguments); EASTDC_API int Vfprintf(FILE* EA_RESTRICT pFile, const char16_t* EA_RESTRICT pFormat, va_list arguments); @@ -239,12 +239,12 @@ namespace StdC /// Snprintf: Print to a string, with capacity specified, same as the C snprintf function. /// Dprintf: Print to a debug output destination (e.g. OutputDebugString on Microsoft platforms). /// - EASTDC_API int Cprintf(WriteFunction8 pWriteFunction, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, ...); - EASTDC_API int Fprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFormat, ...); - EASTDC_API int Printf(const char8_t* EA_RESTRICT pFormat, ...); - EASTDC_API int Sprintf(char8_t* EA_RESTRICT pDestination, const char8_t* EA_RESTRICT pFormat, ...); - EASTDC_API int Snprintf(char8_t* EA_RESTRICT pDestination, size_t n, const char8_t* EA_RESTRICT pFormat, ...); - EASTDC_API int Dprintf(const char8_t* EA_RESTRICT pFormat, ...); + EASTDC_API int Cprintf(WriteFunction8 pWriteFunction, void* EA_RESTRICT pContext, const char* EA_RESTRICT pFormat, ...); + EASTDC_API int Fprintf(FILE* EA_RESTRICT pFile, const char* EA_RESTRICT pFormat, ...); + EASTDC_API int Printf(const char* EA_RESTRICT pFormat, ...); + EASTDC_API int Sprintf(char* EA_RESTRICT pDestination, const char* EA_RESTRICT pFormat, ...); + EASTDC_API int Snprintf(char* EA_RESTRICT pDestination, size_t n, const char* EA_RESTRICT pFormat, ...); + EASTDC_API int Dprintf(const char* EA_RESTRICT pFormat, ...); EASTDC_API int Cprintf(WriteFunction16 pWriteFunction, void* EA_RESTRICT pContext, const char16_t* EA_RESTRICT pFormat, ...); EASTDC_API int Fprintf(FILE* EA_RESTRICT pFile, const char16_t* EA_RESTRICT pFormat, ...); @@ -286,19 +286,8 @@ namespace StdC // Deprecated functionality /////////////////////////////////////////////////////////////////////////// - // There was an update which caused the WriteFunction to have a new parameter (WriteFunctionState), - // but there may be old user code which uses the original WriteFunction which didn't take this - // parameter. So we implement support for the old WriteFunction type for the time being. - typedef int (*WriteFunction8Old) (const char8_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8); - typedef int (*WriteFunction16Old)(const char16_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext16); - - EASTDC_API int Cprintf(WriteFunction8Old pWriteFunction, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, ...); - EASTDC_API int Cprintf(WriteFunction16Old pWriteFunction, void* EA_RESTRICT pContext, const char16_t* EA_RESTRICT pFormat, ...); - EASTDC_API int Vcprintf(WriteFunction8Old pWriteFunction8, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int Vcprintf(WriteFunction16Old pWriteFunction16, void* EA_RESTRICT pContext, const char16_t* EA_RESTRICT pFormat, va_list arguments); - #if EASTDC_VSNPRINTF8_ENABLED - EASTDC_API int Vsnprintf8(char8_t* EA_RESTRICT pDestination, size_t n, const char8_t* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int Vsnprintf8(char* EA_RESTRICT pDestination, size_t n, const char* EA_RESTRICT pFormat, va_list arguments); EASTDC_API int Vsnprintf16(char16_t* EA_RESTRICT pDestination, size_t n, const char16_t* EA_RESTRICT pFormat, va_list arguments); EASTDC_API int Vsnprintf32(char32_t* EA_RESTRICT pDestination, size_t n, const char32_t* EA_RESTRICT pFormat, va_list arguments); #if defined(EA_WCHAR_UNIQUE) && EA_WCHAR_UNIQUE diff --git a/include/EAStdC/EASprintfOrdered.h b/include/EAStdC/EASprintfOrdered.h index 1f7d36f..7bae11e 100644 --- a/include/EAStdC/EASprintfOrdered.h +++ b/include/EAStdC/EASprintfOrdered.h @@ -57,11 +57,11 @@ namespace StdC /// See EASprintf.h for documentation on the Printf family. /// See also http://www.cplusplus.com/reference/clibrary/cstdio/printf.html /// - EASTDC_API int OCprintf(WriteFunction8 pWriteFunction, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, ...); - EASTDC_API int OFprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFormat, ...); - EASTDC_API int OPrintf(const char8_t* EA_RESTRICT pFormat, ...); - EASTDC_API int OSprintf(char8_t* EA_RESTRICT pDestination, const char8_t* EA_RESTRICT pFormat, ...); - EASTDC_API int OSnprintf(char8_t* EA_RESTRICT pDestination, size_t n, const char8_t* EA_RESTRICT pFormat, ...); + EASTDC_API int OCprintf(WriteFunction8 pWriteFunction, void* EA_RESTRICT pContext, const char* EA_RESTRICT pFormat, ...); + EASTDC_API int OFprintf(FILE* EA_RESTRICT pFile, const char* EA_RESTRICT pFormat, ...); + EASTDC_API int OPrintf(const char* EA_RESTRICT pFormat, ...); + EASTDC_API int OSprintf(char* EA_RESTRICT pDestination, const char* EA_RESTRICT pFormat, ...); + EASTDC_API int OSnprintf(char* EA_RESTRICT pDestination, size_t n, const char* EA_RESTRICT pFormat, ...); EASTDC_API int OCprintf(WriteFunction16 pWriteFunction, void* EA_RESTRICT pContext, const char16_t* EA_RESTRICT pFormat, ...); EASTDC_API int OFprintf(FILE* EA_RESTRICT pFile, const char16_t* EA_RESTRICT pFormat, ...); @@ -83,12 +83,12 @@ namespace StdC /// See EASprintf.h for documentation on the Vprintf family. /// See also http://www.cplusplus.com/reference/clibrary/cstdio/printf.html /// - EASTDC_API int OVcprintf(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int OVfprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int OVprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int OVsprintf(char8_t* EA_RESTRICT pDestination, const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int OVsnprintf(char8_t* EA_RESTRICT pDestination, size_t n, const char8_t* EA_RESTRICT pFormat, va_list arguments); - EASTDC_API int OVscprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int OVcprintf(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pContext, const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int OVfprintf(FILE* EA_RESTRICT pFile, const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int OVprintf(const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int OVsprintf(char* EA_RESTRICT pDestination, const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int OVsnprintf(char* EA_RESTRICT pDestination, size_t n, const char* EA_RESTRICT pFormat, va_list arguments); + EASTDC_API int OVscprintf(const char* EA_RESTRICT pFormat, va_list arguments); EASTDC_API int OVcprintf(WriteFunction16 pWriteFunction16, void* EA_RESTRICT pContext, const char16_t* EA_RESTRICT pFormat, va_list arguments); EASTDC_API int OVfprintf(FILE* EA_RESTRICT pFile, const char16_t* EA_RESTRICT pFormat, va_list arguments); diff --git a/include/EAStdC/EAString.h b/include/EAStdC/EAString.h index 37e9577..91df780 100644 --- a/include/EAStdC/EAString.h +++ b/include/EAStdC/EAString.h @@ -13,10 +13,10 @@ // char_t* Strcpy(char_t* pDestination, const char_t* pSource); // char_t* Strncpy(char_t* pDestination, const char_t* pSource, size_t n); // size_t Strlcpy(char_t* pDestination, const char_t* pSource, size_t n); -// int Strlcpy(char16_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); -// int Strlcpy(char8_t* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); +// int Strlcpy(char16_t* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); +// int Strlcpy(char* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); // size_t Strlen(const char_t* pString); -// size_t StrlenUTF8Decoded(const char8_t* pString); +// size_t StrlenUTF8Decoded(const char* pString); // size_t StrlenUTF8Encoded(const char16_t* pString); // char_t* Strend(const char_t* pString); // size_t Strxfrm(char_t* pDest, const char_t* pSource, size_t n); @@ -124,12 +124,15 @@ static const size_t kSizeTypeUnset = (size_t)~0; /// Returns the length of pString, not including the terminating 0 char. /// This function acts the same as strlen. /// -EASTDC_API size_t Strlen(const char8_t* pString); +EASTDC_API size_t Strlen(const char* pString); EASTDC_API size_t Strlen(const char16_t* pString); EASTDC_API size_t Strlen(const char32_t* pString); #if EA_WCHAR_UNIQUE EASTDC_API size_t Strlen(const wchar_t* pString); #endif +#if EA_CHAR8_UNIQUE + inline size_t Strlen(const char8_t* pString) { return Strlen((const char*)pString); } +#endif /// StrlenUTF8Decoded /// @@ -140,7 +143,7 @@ EASTDC_API size_t Strlen(const char32_t* pString); /// /// Note: this function is a duplicate of the EATextUtil.h UTF8Length(const char16_t*) function and is deprecated in favor of the EATextUtil.h version. /// -EASTDC_API size_t StrlenUTF8Decoded(const char8_t* pString); +EASTDC_API size_t StrlenUTF8Decoded(const char* pString); /// StrlenUTF8Encoded @@ -150,7 +153,7 @@ EASTDC_API size_t StrlenUTF8Decoded(const char8_t* pString); /// the same as Strlen. For text with Unicode values > 0x7f, this function /// will return a value greater that Strlen. /// -/// Note: this function is a duplicate of the EATextUtil.h UTF8Length(const char8_t*) function and is deprecated in favor of the EATextUtil.h version. +/// Note: this function is a duplicate of the EATextUtil.h UTF8Length(const char*) function and is deprecated in favor of the EATextUtil.h version. /// EASTDC_API size_t StrlenUTF8Encoded(const char16_t* pString); EASTDC_API size_t StrlenUTF8Encoded(const char32_t* pString); @@ -160,7 +163,7 @@ EASTDC_API size_t StrlenUTF8Encoded(const char32_t* pString); /// /// Returns the end of the string, which is the same thing as (pStr + Strlen(pStr)). /// -EASTDC_API char8_t* Strend(const char8_t* pString); +EASTDC_API char* Strend(const char* pString); EASTDC_API char16_t* Strend(const char16_t* pString); EASTDC_API char32_t* Strend(const char32_t* pString); #if EA_WCHAR_UNIQUE @@ -174,7 +177,7 @@ EASTDC_API char32_t* Strend(const char32_t* pString); /// Considering using Strlcpy as a safe alternative to Strcat. /// This function acts the same as strcpy. /// -EASTDC_API char8_t* Strcpy(char8_t* pDestination, const char8_t* pSource); +EASTDC_API char* Strcpy(char* pDestination, const char* pSource); EASTDC_API char16_t* Strcpy(char16_t* pDestination, const char16_t* pSource); EASTDC_API char32_t* Strcpy(char32_t* pDestination, const char32_t* pSource); #if EA_WCHAR_UNIQUE @@ -200,7 +203,7 @@ EASTDC_API char32_t* Strcpy(char32_t* pDestination, const char32_t* pSource); /// Strncpy(buffer, pSomeString, 32); /// buffer[31] = 0; /// -EASTDC_API char8_t* Strncpy(char8_t* pDestination, const char8_t* pSource, size_t n); +EASTDC_API char* Strncpy(char* pDestination, const char* pSource, size_t n); EASTDC_API char16_t* Strncpy(char16_t* pDestination, const char16_t* pSource, size_t n); EASTDC_API char32_t* Strncpy(char32_t* pDestination, const char32_t* pSource, size_t n); #if EA_WCHAR_UNIQUE @@ -215,7 +218,7 @@ EASTDC_API char32_t* Strncpy(char32_t* pDestination, const char32_t* pSource, si /// bugs that may be in the StringnCopy function. /// Users are advised to use Strlcat instead of Strncat or StringnCat. /// -EASTDC_API char8_t* StringnCopy(char8_t* pDestination, const char8_t* pSource, size_t n); +EASTDC_API char* StringnCopy(char* pDestination, const char* pSource, size_t n); EASTDC_API char16_t* StringnCopy(char16_t* pDestination, const char16_t* pSource, size_t n); EASTDC_API char32_t* StringnCopy(char32_t* pDestination, const char32_t* pSource, size_t n); #if EA_WCHAR_UNIQUE @@ -276,7 +279,7 @@ EASTDC_API char32_t* StringnCopy(char32_t* pDestination, const char32_t* pSource /// if(Strlcat(path, file, EAArrayCount(path)) >= EAArrayCount(path)) /// goto toolong; /// -EASTDC_API size_t Strlcpy(char8_t* pDestination, const char8_t* pSource, size_t nDestCapacity); +EASTDC_API size_t Strlcpy(char* pDestination, const char* pSource, size_t nDestCapacity); EASTDC_API size_t Strlcpy(char16_t* pDestination, const char16_t* pSource, size_t nDestCapacity); EASTDC_API size_t Strlcpy(char32_t* pDestination, const char32_t* pSource, size_t nDestCapacity); @@ -294,26 +297,55 @@ EASTDC_API size_t Strlcpy(char32_t* pDestination, const char32_t* pSource, size_ /// nSourceLength is the strlen of the source and thus doesn't include the source's /// own trailing 0 byte. /// -EASTDC_API int Strlcpy(char16_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); -EASTDC_API int Strlcpy(char8_t* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); +EASTDC_API int Strlcpy(char16_t* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); +EASTDC_API int Strlcpy(char* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); -EASTDC_API int Strlcpy(char32_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); -EASTDC_API int Strlcpy(char8_t* pDestination, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); +EASTDC_API int Strlcpy(char32_t* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); +EASTDC_API int Strlcpy(char* pDestination, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); EASTDC_API int Strlcpy(char32_t* pDest, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); EASTDC_API int Strlcpy(char16_t* pDest, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); +#if EA_CHAR8_UNIQUE + inline int Strlcpy(char8_t* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset) + { + return (int)Strlcpy((char*)pDestination, pSource, nDestCapacity); + } + inline int Strlcpy(char* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset) + { + return (int)Strlcpy(pDestination, (const char*)pSource, nDestCapacity); + } + + inline int Strlcpy(char8_t* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset) + { + return (int)Strlcpy((char*)pDestination, pSource, nDestCapacity, nSourceLength); + } + inline int Strlcpy(char16_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset) + { + return (int)Strlcpy(pDestination, (const char*)pSource, nDestCapacity, nSourceLength); + } + + inline int Strlcpy(char8_t* pDestination, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset) + { + return (int)Strlcpy((char*)pDestination, pSource, nDestCapacity, nSourceLength); + } + inline int Strlcpy(char32_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset) + { + return (int)Strlcpy(pDestination, (const char*)pSource, nDestCapacity, nSourceLength); + } +#endif + #if EA_WCHAR_UNIQUE - EASTDC_API int Strlcpy(char8_t* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); + EASTDC_API int Strlcpy(char* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); EASTDC_API int Strlcpy(char16_t* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); EASTDC_API int Strlcpy(char32_t* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); - EASTDC_API int Strlcpy(wchar_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); + EASTDC_API int Strlcpy(wchar_t* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); EASTDC_API int Strlcpy(wchar_t* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); EASTDC_API int Strlcpy(wchar_t* pDestination, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength = kSizeTypeUnset); #endif // To consider: Enable this for completeness with the above: -//EASTDC_API int Strlcpy(char8_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength); // nSourceLength = kSizeTypeUnset +//EASTDC_API int Strlcpy(char* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength); // nSourceLength = kSizeTypeUnset //EASTDC_API int Strlcpy(char16_t* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength); // nSourceLength = kSizeTypeUnset. We can't define the default parameter because if we did then Strlcpy would conflict with the other version of Strlcpy. //EASTDC_API int Strlcpy(char32_t* pDestination, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength); // nSourceLength = kSizeTypeUnset. We can't define the default parameter because if we did then Strlcpy would conflict with the other version of Strlcpy. @@ -336,19 +368,19 @@ EASTDC_API int Strlcpy(char16_t* pDest, const char32_t* pSource, size_t nDestCap /// the string copy will stop after a null is found. In that case, nSourceUsed will have the /// value of nSourceLength. /// -EASTDC_API bool Strlcpy(char8_t* pDest, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); -EASTDC_API bool Strlcpy(char8_t* pDest, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); -EASTDC_API bool Strlcpy(char16_t* pDest, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); +EASTDC_API bool Strlcpy(char* pDest, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); +EASTDC_API bool Strlcpy(char* pDest, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); +EASTDC_API bool Strlcpy(char16_t* pDest, const char* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); EASTDC_API bool Strlcpy(char16_t* pDest, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); -EASTDC_API bool Strlcpy(char32_t* pDest, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); +EASTDC_API bool Strlcpy(char32_t* pDest, const char* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); EASTDC_API bool Strlcpy(char32_t* pDest, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); #if EA_WCHAR_UNIQUE - EASTDC_API bool Strlcpy(char8_t* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); - EASTDC_API bool Strlcpy(char16_t* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); - EASTDC_API bool Strlcpy(char32_t* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); - EASTDC_API bool Strlcpy(wchar_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); - EASTDC_API bool Strlcpy(wchar_t* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); - EASTDC_API bool Strlcpy(wchar_t* pDestination, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); + EASTDC_API bool Strlcpy(char* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); + EASTDC_API bool Strlcpy(char16_t* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); + EASTDC_API bool Strlcpy(char32_t* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); + EASTDC_API bool Strlcpy(wchar_t* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); + EASTDC_API bool Strlcpy(wchar_t* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); + EASTDC_API bool Strlcpy(wchar_t* pDestination, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed); #endif /// Strlcpy @@ -537,7 +569,7 @@ inline Dest Strlcpy(const Source& s) /// Implements a generic STL/EASTL 8 <--> 16 conversion via Strlcpy. /// /// Example usage: -/// eastl::string16 s16 = Strlcpy("hello world"); +/// eastl::string16 s16 = Strlcpy("hello world"); /// namespace Internal { @@ -589,7 +621,7 @@ inline Dest Strlcpy(const Source* pSource, size_t sourceLength = kSizeTypeUnset) /// is (Strlen(pSource) + Strlen(pDestination) + 1). /// Considering using Strlcat as a safer alternative to Strcat. /// -EASTDC_API char8_t* Strcat(char8_t* pDestination, const char8_t* pSource); +EASTDC_API char* Strcat(char* pDestination, const char* pSource); EASTDC_API char16_t* Strcat(char16_t* pDestination, const char16_t* pSource); EASTDC_API char32_t* Strcat(char32_t* pDestination, const char32_t* pSource); #if EA_WCHAR_UNIQUE @@ -604,7 +636,7 @@ EASTDC_API char32_t* Strcat(char32_t* pDestination, const char32_t* pSource); /// Considering using Strlcat as a safer alternative to Strncat. /// This function acts the same as strncat /// -EASTDC_API char8_t* Strncat(char8_t* pDestination, const char8_t* pSource, size_t n); +EASTDC_API char* Strncat(char* pDestination, const char* pSource, size_t n); EASTDC_API char16_t* Strncat(char16_t* pDestination, const char16_t* pSource, size_t n); EASTDC_API char32_t* Strncat(char32_t* pDestination, const char32_t* pSource, size_t n); #if EA_WCHAR_UNIQUE @@ -619,7 +651,7 @@ EASTDC_API char32_t* Strncat(char32_t* pDestination, const char32_t* pSource, si /// bugs that may be in the StringnCopy function. /// Users are advised to use Strlcat instead of Strncat or StringnCat. /// -EASTDC_API char8_t* StringnCat(char8_t* pDestination, const char8_t* pSource, size_t n); +EASTDC_API char* StringnCat(char* pDestination, const char* pSource, size_t n); EASTDC_API char16_t* StringnCat(char16_t* pDestination, const char16_t* pSource, size_t n); EASTDC_API char32_t* StringnCat(char32_t* pDestination, const char32_t* pSource, size_t n); #if EA_WCHAR_UNIQUE @@ -681,25 +713,25 @@ EASTDC_API char32_t* StringnCat(char32_t* pDestination, const char32_t* pSource, /// if(Strlcat(path, file, EAArrayCount(path)) >= EAArrayCount(path)) /// goto toolong; /// -EASTDC_API size_t Strlcat(char8_t* pDestination, const char8_t* pSource, size_t nDestCapacity); +EASTDC_API size_t Strlcat(char* pDestination, const char* pSource, size_t nDestCapacity); EASTDC_API size_t Strlcat(char16_t* pDestination, const char16_t* pSource, size_t nDestCapacity); EASTDC_API size_t Strlcat(char32_t* pDestination, const char32_t* pSource, size_t nDestCapacity); #if EA_WCHAR_UNIQUE - EASTDC_API size_t Strlcat(wchar_t* pDestination, const wchar_t* pSource, size_t nDestCapacity); - EASTDC_API size_t Strlcat(wchar_t* pDestination, const char8_t* pSource, size_t nDestCapacity); - EASTDC_API size_t Strlcat(wchar_t* pDestination, const char16_t* pSource, size_t nDestCapacity); - EASTDC_API size_t Strlcat(wchar_t* pDestination, const char32_t* pSource, size_t nDestCapacity); - EASTDC_API size_t Strlcat(char8_t* pDestination, const wchar_t* pSource, size_t nDestCapacity); - EASTDC_API size_t Strlcat(char16_t* pDestination, const wchar_t* pSource, size_t nDestCapacity); - EASTDC_API size_t Strlcat(char32_t* pDestination, const wchar_t* pSource, size_t nDestCapacity); + EASTDC_API size_t Strlcat(wchar_t* pDestination, const wchar_t* pSource, size_t nDestCapacity); + EASTDC_API size_t Strlcat(wchar_t* pDestination, const char* pSource, size_t nDestCapacity); + EASTDC_API size_t Strlcat(wchar_t* pDestination, const char16_t* pSource, size_t nDestCapacity); + EASTDC_API size_t Strlcat(wchar_t* pDestination, const char32_t* pSource, size_t nDestCapacity); + EASTDC_API size_t Strlcat(char* pDestination, const wchar_t* pSource, size_t nDestCapacity); + EASTDC_API size_t Strlcat(char16_t* pDestination, const wchar_t* pSource, size_t nDestCapacity); + EASTDC_API size_t Strlcat(char32_t* pDestination, const wchar_t* pSource, size_t nDestCapacity); #endif // UTF8 <-> UTF16 <-> UTF32 encoding conversion -EASTDC_API size_t Strlcat(char16_t* pDestination, const char8_t* pSource, size_t nDestCapacity); -EASTDC_API size_t Strlcat(char8_t* pDestination, const char16_t* pSource, size_t nDestCapacity); +EASTDC_API size_t Strlcat(char16_t* pDestination, const char* pSource, size_t nDestCapacity); +EASTDC_API size_t Strlcat(char* pDestination, const char16_t* pSource, size_t nDestCapacity); -EASTDC_API size_t Strlcat(char32_t* pDestination, const char8_t* pSource, size_t nDestCapacity); -EASTDC_API size_t Strlcat(char8_t* pDestination, const char32_t* pSource, size_t nDestCapacity); +EASTDC_API size_t Strlcat(char32_t* pDestination, const char* pSource, size_t nDestCapacity); +EASTDC_API size_t Strlcat(char* pDestination, const char32_t* pSource, size_t nDestCapacity); EASTDC_API size_t Strlcat(char16_t* pDestination, const char32_t* pSource, size_t nDestCapacity); EASTDC_API size_t Strlcat(char32_t* pDestination, const char16_t* pSource, size_t nDestCapacity); @@ -713,7 +745,7 @@ EASTDC_API size_t Strlcat(char32_t* pDestination, const char16_t* pSource, size /// eastl::wstring sW(L"hello "); /// eastl::string8 s8("world"); /// -/// EA::StdC::Strlcat(sW, s8); // char8_t -> wchar_t. Becomes L"hello world." +/// EA::StdC::Strlcat(sW, s8); // char -> wchar_t. Becomes L"hello world." /// namespace Internal { @@ -758,7 +790,7 @@ inline bool Strlcat(Dest& d, const Source& s) /// /// Example usage: /// eastl::wstring sW(L"hello "); -/// EA::StdC::Strlcat(sW, "world"); // char8_t -> wchar_t. Becomes L"hello world." +/// EA::StdC::Strlcat(sW, "world"); // char -> wchar_t. Becomes L"hello world." /// namespace Internal { @@ -812,7 +844,7 @@ inline bool Strlcat(Dest& d, const Source* pSource, size_t sourceLength = kSizeT /// doesn't do any transformation other than simply copy. /// This is similar to the strxfrm C function. /// -EASTDC_API size_t Strxfrm(char8_t* pDest, const char8_t* pSource, size_t n); +EASTDC_API size_t Strxfrm(char* pDest, const char* pSource, size_t n); EASTDC_API size_t Strxfrm(char16_t* pDest, const char16_t* pSource, size_t n); EASTDC_API size_t Strxfrm(char32_t* pDest, const char32_t* pSource, size_t n); #if EA_WCHAR_UNIQUE @@ -827,7 +859,7 @@ EASTDC_API size_t Strxfrm(char32_t* pDest, const char32_t* pSource, size_t n); /// If Strdup resides in a DLL or similar kind of independent library, Strldel is required. /// This is similar to the strdup C function. /// -EASTDC_API char8_t* Strdup(const char8_t* pString); +EASTDC_API char* Strdup(const char* pString); EASTDC_API char16_t* Strdup(const char16_t* pString); EASTDC_API char32_t* Strdup(const char32_t* pString); #if EA_WCHAR_UNIQUE @@ -839,7 +871,7 @@ EASTDC_API char32_t* Strdup(const char32_t* pString); /// /// Deletes a string returned by Strdup. /// -EASTDC_API void Strdel(char8_t* pString); +EASTDC_API void Strdel(char* pString); EASTDC_API void Strdel(char16_t* pString); EASTDC_API void Strdel(char32_t* pString); #if EA_WCHAR_UNIQUE @@ -856,7 +888,7 @@ EASTDC_API void Strdel(char32_t* pString); /// The Unicode module may be split off into a unique package by the time you read this. /// This is similar to the sometimes seen _strupr C function. /// -EASTDC_API char8_t* Strupr(char8_t* pString); +EASTDC_API char* Strupr(char* pString); EASTDC_API char16_t* Strupr(char16_t* pString); EASTDC_API char32_t* Strupr(char32_t* pString); #if EA_WCHAR_UNIQUE @@ -873,7 +905,7 @@ EASTDC_API char32_t* Strupr(char32_t* pString); /// The Unicode module may be split off into a unique package by the time you read this. /// This is similar to the sometimes seen _strlwr C function. /// -EASTDC_API char8_t* Strlwr(char8_t* pString); +EASTDC_API char* Strlwr(char* pString); EASTDC_API char16_t* Strlwr(char16_t* pString); EASTDC_API char32_t* Strlwr(char32_t* pString); #if EA_WCHAR_UNIQUE @@ -894,7 +926,7 @@ EASTDC_API char32_t* Strlwr(char32_t* pString); /// /// This function is currently provided for compatibility with the rwstdc package. /// -EASTDC_API char8_t* Strmix(char8_t* pDestination, const char8_t* pSource, const char8_t* pDelimiters); +EASTDC_API char* Strmix(char* pDestination, const char* pSource, const char* pDelimiters); EASTDC_API char16_t* Strmix(char16_t* pDestination, const char16_t* pSource, const char16_t* pDelimiters); EASTDC_API char32_t* Strmix(char32_t* pDestination, const char32_t* pSource, const char32_t* pDelimiters); #if EA_WCHAR_UNIQUE @@ -908,7 +940,7 @@ EASTDC_API char32_t* Strmix(char32_t* pDestination, const char32_t* pSource, con /// The null-terminating character is included as part of the string and can also be searched. /// This is similar to the strchr C function. /// -EASTDC_API char8_t* Strchr(const char8_t* pString, int c); +EASTDC_API char* Strchr(const char* pString, int c); EASTDC_API char16_t* Strchr(const char16_t* pString, char16_t c); EASTDC_API char32_t* Strchr(const char32_t* pString, char32_t c); #if EA_WCHAR_UNIQUE @@ -923,7 +955,7 @@ EASTDC_API char32_t* Strchr(const char32_t* pString, char32_t c); /// This differs from some implementations that let you search past the null-terminator of pString. If you'd like to do that, use EA::StdC::Memchr /// Some other C library strnchr functions have the last two arguments switched relative to this version. /// -EASTDC_API char8_t* Strnchr(const char8_t* pString, int c, size_t n); +EASTDC_API char* Strnchr(const char* pString, int c, size_t n); EASTDC_API char16_t* Strnchr(const char16_t* pString, char16_t c, size_t n); EASTDC_API char32_t* Strnchr(const char32_t* pString, char32_t c, size_t n); #if EA_WCHAR_UNIQUE @@ -939,7 +971,7 @@ EASTDC_API char32_t* Strnchr(const char32_t* pString, char32_t c, size_t n); /// the length of pString1 if none of the characters included in pString2 is in pString1. /// This is similar to the strcspn C function. /// -EASTDC_API size_t Strcspn(const char8_t* pString1, const char8_t* pString2); +EASTDC_API size_t Strcspn(const char* pString1, const char* pString2); EASTDC_API size_t Strcspn(const char16_t* pString1, const char16_t* pString2); EASTDC_API size_t Strcspn(const char32_t* pString1, const char32_t* pString2); #if EA_WCHAR_UNIQUE @@ -954,7 +986,7 @@ EASTDC_API size_t Strcspn(const char32_t* pString1, const char32_t* pString2); /// does not includes the terminating null characters. /// This is similar to the strpbrk C function. /// -EASTDC_API char8_t* Strpbrk(const char8_t* pString1, const char8_t* pString2); +EASTDC_API char* Strpbrk(const char* pString1, const char* pString2); EASTDC_API char16_t* Strpbrk(const char16_t* pString1, const char16_t* pString2); EASTDC_API char32_t* Strpbrk(const char32_t* pString1, const char32_t* pString2); #if EA_WCHAR_UNIQUE @@ -968,7 +1000,7 @@ EASTDC_API char32_t* Strpbrk(const char32_t* pString1, const char32_t* pString2) /// The null-terminating character is included as part of the string and can also be searched. /// This is similar to the strrchr C function. /// -EASTDC_API char8_t* Strrchr(const char8_t* pString, int c); +EASTDC_API char* Strrchr(const char* pString, int c); EASTDC_API char16_t* Strrchr(const char16_t* pString, char16_t c); EASTDC_API char32_t* Strrchr(const char32_t* pString, char32_t c); #if EA_WCHAR_UNIQUE @@ -980,7 +1012,7 @@ EASTDC_API char32_t* Strrchr(const char32_t* pString, char32_t c); /// /// This is similar to the strspn C function. /// -EASTDC_API size_t Strspn(const char8_t* pString, const char8_t* pSubString); +EASTDC_API size_t Strspn(const char* pString, const char* pSubString); EASTDC_API size_t Strspn(const char16_t* pString, const char16_t* pSubString); EASTDC_API size_t Strspn(const char32_t* pString, const char32_t* pSubString); #if EA_WCHAR_UNIQUE @@ -999,7 +1031,7 @@ EASTDC_API size_t Strspn(const char32_t* pString, const char32_t* pSubString); /// it could break users who expect a non-const return value from the const /// argument version. /// -EASTDC_API char8_t* Strstr(const char8_t* pString, const char8_t* pSubString); +EASTDC_API char* Strstr(const char* pString, const char* pSubString); EASTDC_API char16_t* Strstr(const char16_t* pString, const char16_t* pSubString); EASTDC_API char32_t* Strstr(const char32_t* pString, const char32_t* pSubString); #if EA_WCHAR_UNIQUE @@ -1017,7 +1049,7 @@ EASTDC_API char32_t* Strstr(const char32_t* pString, const char32_t* pSubString) /// This is similar to the stristr and wcsstr C functions. See the notes for /// those functions for some additional info. /// -EASTDC_API char8_t* Stristr(const char8_t* pString, const char8_t* pSubString); +EASTDC_API char* Stristr(const char* pString, const char* pSubString); EASTDC_API char16_t* Stristr(const char16_t* pString, const char16_t* pSubString); EASTDC_API char32_t* Stristr(const char32_t* pString, const char32_t* pSubString); #if EA_WCHAR_UNIQUE @@ -1032,7 +1064,7 @@ EASTDC_API char32_t* Stristr(const char32_t* pString, const char32_t* pSubString /// This is similar to the strrstr C function. See the notes for /// Strstr for some additional info. /// -EASTDC_API char8_t* Strrstr(const char8_t* pString, const char8_t* pSubString); +EASTDC_API char* Strrstr(const char* pString, const char* pSubString); EASTDC_API char16_t* Strrstr(const char16_t* pString, const char16_t* pSubString); EASTDC_API char32_t* Strrstr(const char32_t* pString, const char32_t* pSubString); #if EA_WCHAR_UNIQUE @@ -1047,7 +1079,7 @@ EASTDC_API char32_t* Strrstr(const char32_t* pString, const char32_t* pSubString /// This is similar to the strirstr C function. See the notes for /// Strstr for some additional info. /// -EASTDC_API char8_t* Strirstr(const char8_t* pString, const char8_t* pSubString); +EASTDC_API char* Strirstr(const char* pString, const char* pSubString); EASTDC_API char16_t* Strirstr(const char16_t* pString, const char16_t* pSubString); EASTDC_API char32_t* Strirstr(const char32_t* pString, const char32_t* pSubString); #if EA_WCHAR_UNIQUE @@ -1061,7 +1093,7 @@ EASTDC_API char32_t* Strirstr(const char32_t* pString, const char32_t* pSubStrin /// Both strings must be non-null, but either can be empty. /// An empty pPrefix results in success, regardless of what pString is. /// -EASTDC_API bool Strstart(const char8_t* pString, const char8_t* pPrefix); +EASTDC_API bool Strstart(const char* pString, const char* pPrefix); EASTDC_API bool Strstart(const char16_t* pString, const char16_t* pPrefix); EASTDC_API bool Strstart(const char32_t* pString, const char32_t* pPrefix); #if EA_WCHAR_UNIQUE @@ -1076,7 +1108,7 @@ EASTDC_API bool Strstart(const char32_t* pString, const char32_t* pPrefix); /// An empty pPrefix results in success, regardless of what pString is. /// Supports ASCII case comparisons only. /// -EASTDC_API bool Stristart(const char8_t* pString, const char8_t* pPrefix); +EASTDC_API bool Stristart(const char* pString, const char* pPrefix); EASTDC_API bool Stristart(const char16_t* pString, const char16_t* pPrefix); EASTDC_API bool Stristart(const char32_t* pString, const char32_t* pPrefix); #if EA_WCHAR_UNIQUE @@ -1094,7 +1126,7 @@ EASTDC_API bool Stristart(const char32_t* pString, const char32_t* pPrefix); /// If stringLength is the default value then it will be calculated, resulting in /// slower execution than otherwise. /// -EASTDC_API bool Strend(const char8_t* pString, const char8_t* pSuffix, size_t stringLength = kSizeTypeUnset, size_t suffixLength = kSizeTypeUnset); +EASTDC_API bool Strend(const char* pString, const char* pSuffix, size_t stringLength = kSizeTypeUnset, size_t suffixLength = kSizeTypeUnset); EASTDC_API bool Strend(const char16_t* pString, const char16_t* pSuffix, size_t stringLength = kSizeTypeUnset, size_t suffixLength = kSizeTypeUnset); EASTDC_API bool Strend(const char32_t* pString, const char32_t* pSuffix, size_t stringLength = kSizeTypeUnset, size_t suffixLength = kSizeTypeUnset); @@ -1108,7 +1140,7 @@ EASTDC_API bool Strend(const char32_t* pString, const char32_t* pSuffix, size_t /// slower execution than otherwise. /// Supports ASCII case comparisons only. /// -EASTDC_API bool Striend(const char8_t* pString, const char8_t* pSuffix, size_t stringLength = kSizeTypeUnset, size_t suffixLength = kSizeTypeUnset); +EASTDC_API bool Striend(const char* pString, const char* pSuffix, size_t stringLength = kSizeTypeUnset, size_t suffixLength = kSizeTypeUnset); EASTDC_API bool Striend(const char16_t* pString, const char16_t* pSuffix, size_t stringLength = kSizeTypeUnset, size_t suffixLength = kSizeTypeUnset); EASTDC_API bool Striend(const char32_t* pString, const char32_t* pSuffix, size_t stringLength = kSizeTypeUnset, size_t suffixLength = kSizeTypeUnset); @@ -1152,23 +1184,23 @@ EASTDC_API bool Striend(const char32_t* pString, const char32_t* pSuffix, size_t /// from pContext and behave as described above. /// /// Example: -/// char8_t* pContext = NULL; -/// char8_t* pString = "000\t000\n000\t000"; -/// char8_t* pResult; +/// char* pContext = NULL; +/// char* pString = "000\t000\n000\t000"; +/// char* pResult; /// /// while((pResult = Strtok(pContext ? NULL : pString, "\t\n", &pContext)) != NULL) /// printf("%s\n", pResult); /// /// Example: -/// char8_t* p = "-abc-=-def"; -/// char8_t* p1; -/// char8_t* r; +/// char* p = "-abc-=-def"; +/// char* p1; +/// char* r; /// /// r = Strtok8(p, "-", &p1); // r = "abc", p1 = "=-def", p = "abc\0=-def" /// r = Strtok8(NULL, "-=", &p1); // r = "def", p1 = NULL, p = "abc\0=-def" /// r = Strtok8(NULL, "=", &p1); // r = NULL, p1 = NULL, p = "abc\0=-def" /// -EASTDC_API char8_t* Strtok(char8_t* pString, const char8_t* pDelimiters, char8_t** pContext); +EASTDC_API char* Strtok(char* pString, const char* pDelimiters, char** pContext); EASTDC_API char16_t* Strtok(char16_t* pString, const char16_t* pDelimiters, char16_t** pContext); EASTDC_API char32_t* Strtok(char32_t* pString, const char32_t* pDelimiters, char32_t** pContext); #if EA_WCHAR_UNIQUE @@ -1192,7 +1224,7 @@ EASTDC_API char32_t* Strtok(char32_t* pString, const char32_t* pDelimiters, char /// in the string; you may want to try using the parsing functions in EATextUtil.h /// in order to avoid this. /// -EASTDC_API const char8_t* Strtok2(const char8_t* pString, const char8_t* pDelimiters, size_t* pResultLength, bool bFirst); +EASTDC_API const char* Strtok2(const char* pString, const char* pDelimiters, size_t* pResultLength, bool bFirst); EASTDC_API const char16_t* Strtok2(const char16_t* pString, const char16_t* pDelimiters, size_t* pResultLength, bool bFirst); EASTDC_API const char32_t* Strtok2(const char32_t* pString, const char32_t* pDelimiters, size_t* pResultLength, bool bFirst); #if EA_WCHAR_UNIQUE @@ -1203,12 +1235,12 @@ EASTDC_API const char32_t* Strtok2(const char32_t* pString, const char32_t* pDel /// Strset /// /// Sets all characters up to but not including the terminating 0 char in -/// pString with the value c. The char8_t version uses int instead of char8_t +/// pString with the value c. The char version uses int instead of char /// in order to be compatible with the C strset function. /// Returns pString. /// This is similar to the sometimes seen _strset C function. /// -EASTDC_API char8_t* Strset(char8_t* pString, int c); +EASTDC_API char* Strset(char* pString, int c); EASTDC_API char16_t* Strset(char16_t* pString, char16_t c); EASTDC_API char32_t* Strset(char32_t* pString, char32_t c); #if EA_WCHAR_UNIQUE @@ -1222,7 +1254,7 @@ EASTDC_API char32_t* Strset(char32_t* pString, char32_t c); /// Strlen of pString, the Strlen(pString) is used instead of n. /// This is similar to the sometimes seen _strnset C function. /// -EASTDC_API char8_t* Strnset(char8_t* pString, int c, size_t n); +EASTDC_API char* Strnset(char* pString, int c, size_t n); EASTDC_API char16_t* Strnset(char16_t* pString, char16_t c, size_t n); EASTDC_API char32_t* Strnset(char32_t* pString, char32_t c, size_t n); #if EA_WCHAR_UNIQUE @@ -1234,7 +1266,7 @@ EASTDC_API char32_t* Strnset(char32_t* pString, char32_t c, size_t n); /// /// This is similar to the sometimes seen _strrev C function. /// -EASTDC_API char8_t* Strrev(char8_t* pString); +EASTDC_API char* Strrev(char* pString); EASTDC_API char16_t* Strrev(char16_t* pString); EASTDC_API char32_t* Strrev(char32_t* pString); #if EA_WCHAR_UNIQUE @@ -1252,7 +1284,7 @@ EASTDC_API char32_t* Strrev(char32_t* pString); /// that pointer instead of pString. /// This is similar to the sometimes seen strstrip C function. /// -EASTDC_API char8_t* Strstrip(char8_t* pString); +EASTDC_API char* Strstrip(char* pString); EASTDC_API char16_t* Strstrip(char16_t* pString); EASTDC_API char32_t* Strstrip(char32_t* pString); #if EA_WCHAR_UNIQUE @@ -1264,19 +1296,23 @@ EASTDC_API char32_t* Strstrip(char32_t* pString); /// /// This is similar to the strcmp C function. /// -EASTDC_API int Strcmp(const char8_t* pString1, const char8_t* pString2); +EASTDC_API int Strcmp(const char* pString1, const char* pString2); EASTDC_API int Strcmp(const char16_t* pString1, const char16_t* pString2); EASTDC_API int Strcmp(const char32_t* pString1, const char32_t* pString2); #if EA_WCHAR_UNIQUE EASTDC_API int Strcmp(const wchar_t* pString1, const wchar_t* pString2); #endif +#if EA_CHAR8_UNIQUE + inline int Strcmp(const char8_t* pString1, const char8_t* pString2) + { return Strcmp((const char*)pString1, (const char*)pString2); } +#endif /// Strncmp /// /// This is similar to the strncmp C function. /// -EASTDC_API int Strncmp(const char8_t* pString1, const char8_t* pString2, size_t n); +EASTDC_API int Strncmp(const char* pString1, const char* pString2, size_t n); EASTDC_API int Strncmp(const char16_t* pString1, const char16_t* pString2, size_t n); EASTDC_API int Strncmp(const char32_t* pString1, const char32_t* pString2, size_t n); #if EA_WCHAR_UNIQUE @@ -1288,7 +1324,7 @@ EASTDC_API int Strncmp(const char32_t* pString1, const char32_t* pString2, size_ /// /// This is similar to the sometimes seen _stricmp or strcasecmp C function. /// -EASTDC_API int Stricmp(const char8_t* pString1, const char8_t* pString2); +EASTDC_API int Stricmp(const char* pString1, const char* pString2); EASTDC_API int Stricmp(const char16_t* pString1, const char16_t* pString2); EASTDC_API int Stricmp(const char32_t* pString1, const char32_t* pString2); #if EA_WCHAR_UNIQUE @@ -1300,7 +1336,7 @@ EASTDC_API int Stricmp(const char32_t* pString1, const char32_t* pString2); /// /// This is similar to the sometimes seen _strnicmp or strncasecmp C function. /// -EASTDC_API int Strnicmp(const char8_t* pString1, const char8_t* pString2, size_t n); +EASTDC_API int Strnicmp(const char* pString1, const char* pString2, size_t n); EASTDC_API int Strnicmp(const char16_t* pString1, const char16_t* pString2, size_t n); EASTDC_API int Strnicmp(const char32_t* pString1, const char32_t* pString2, size_t n); #if EA_WCHAR_UNIQUE @@ -1340,11 +1376,11 @@ EASTDC_API int Strnicmp(const char32_t* pString1, const char32_t* pString2, size /// EATEST_VERIFY(StrcmpAlnum("abc1.1", "abc1.02") < 0); // Verify that '.' is not treated as a decimal point. /// EATEST_VERIFY(StrcmpAlnum("44", "044") == 0); // Verify that digit spans are treated as base 10 numbers. /// -EASTDC_API int StrcmpAlnum(const char8_t* pString1, const char8_t* pString2); +EASTDC_API int StrcmpAlnum(const char* pString1, const char* pString2); EASTDC_API int StrcmpAlnum(const char16_t* pString1, const char16_t* pString2); // No 32 bit version because this function is deprecated. -EASTDC_API int StricmpAlnum(const char8_t* pString1, const char8_t* pString2); +EASTDC_API int StricmpAlnum(const char* pString1, const char* pString2); EASTDC_API int StricmpAlnum(const char16_t* pString1, const char16_t* pString2); // No 32 bit version because this function is deprecated. @@ -1397,14 +1433,14 @@ EASTDC_API int StricmpAlnum(const char16_t* pString1, const char16_t* pString2); /// EATEST_VERIFY(StrcmpNumeric("abc1.1", "abc1.02") > 0); /// EATEST_VERIFY(StrcmpNumeric("44", "044") == 0); /// -EASTDC_API int StrcmpNumeric (const char8_t* pString1, const char8_t* pString2, size_t length1 = kSizeTypeUnset, size_t length2 = kSizeTypeUnset, char8_t decimal = '.', char8_t thousandsSeparator = ','); +EASTDC_API int StrcmpNumeric (const char* pString1, const char* pString2, size_t length1 = kSizeTypeUnset, size_t length2 = kSizeTypeUnset, char decimal = '.', char thousandsSeparator = ','); EASTDC_API int StrcmpNumeric (const char16_t* pString1, const char16_t* pString2, size_t length1 = kSizeTypeUnset, size_t length2 = kSizeTypeUnset, char16_t decimal = '.', char16_t thousandsSeparator = ','); EASTDC_API int StrcmpNumeric (const char32_t* pString1, const char32_t* pString2, size_t length1 = kSizeTypeUnset, size_t length2 = kSizeTypeUnset, char32_t decimal = '.', char32_t thousandsSeparator = ','); #if EA_WCHAR_UNIQUE EASTDC_API int StrcmpNumeric (const wchar_t* pString1, const wchar_t* pString2, size_t length1 = kSizeTypeUnset, size_t length2 = kSizeTypeUnset, wchar_t decimal = '.', wchar_t thousandsSeparator = ','); #endif -EASTDC_API int StricmpNumeric(const char8_t* pString1, const char8_t* pString2, size_t length1 = kSizeTypeUnset, size_t length2 = kSizeTypeUnset, char8_t decimal = '.', char8_t thousandsSeparator = ','); +EASTDC_API int StricmpNumeric(const char* pString1, const char* pString2, size_t length1 = kSizeTypeUnset, size_t length2 = kSizeTypeUnset, char decimal = '.', char thousandsSeparator = ','); EASTDC_API int StricmpNumeric(const char16_t* pString1, const char16_t* pString2, size_t length1 = kSizeTypeUnset, size_t length2 = kSizeTypeUnset, char16_t decimal = '.', char16_t thousandsSeparator = ','); EASTDC_API int StricmpNumeric(const char32_t* pString1, const char32_t* pString2, size_t length1 = kSizeTypeUnset, size_t length2 = kSizeTypeUnset, char32_t decimal = '.', char32_t thousandsSeparator = ','); #if EA_WCHAR_UNIQUE @@ -1422,7 +1458,7 @@ EASTDC_API int StricmpNumeric(const char32_t* pString1, const char32_t* pString2 /// The Unicode module may be split off into a unique package by the time you read this. /// This is similar to the strcoll C function. /// -EASTDC_API int Strcoll(const char8_t* pString1, const char8_t* pString2); +EASTDC_API int Strcoll(const char* pString1, const char* pString2); EASTDC_API int Strcoll(const char16_t* pString1, const char16_t* pString2); EASTDC_API int Strcoll(const char32_t* pString1, const char32_t* pString2); #if EA_WCHAR_UNIQUE @@ -1437,7 +1473,7 @@ EASTDC_API int Strcoll(const char32_t* pString1, const char32_t* pString2); /// The Unicode module may be split off into a unique package by the time you read this. /// This is similar to the sometimes seen _strncoll C function. /// -EASTDC_API int Strncoll(const char8_t* pString1, const char8_t* pString2, size_t n); +EASTDC_API int Strncoll(const char* pString1, const char* pString2, size_t n); EASTDC_API int Strncoll(const char16_t* pString1, const char16_t* pString2, size_t n); EASTDC_API int Strncoll(const char32_t* pString1, const char32_t* pString2, size_t n); #if EA_WCHAR_UNIQUE @@ -1449,7 +1485,7 @@ EASTDC_API int Strncoll(const char32_t* pString1, const char32_t* pString2, size /// /// This is similar to the sometimes seen _stricoll C function. /// -EASTDC_API int Stricoll(const char8_t* pString1, const char8_t* pString2); +EASTDC_API int Stricoll(const char* pString1, const char* pString2); EASTDC_API int Stricoll(const char16_t* pString1, const char16_t* pString2); EASTDC_API int Stricoll(const char32_t* pString1, const char32_t* pString2); #if EA_WCHAR_UNIQUE @@ -1464,7 +1500,7 @@ EASTDC_API int Stricoll(const char32_t* pString1, const char32_t* pString2); /// The Unicode module may be split off into a unique package by the time you read this. /// This is similar to the sometimes seen _strnicoll C function. /// -EASTDC_API int Strnicoll(const char8_t* pString1, const char8_t* pString2, size_t n); +EASTDC_API int Strnicoll(const char* pString1, const char* pString2, size_t n); EASTDC_API int Strnicoll(const char16_t* pString1, const char16_t* pString2, size_t n); EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, size_t n); #if EA_WCHAR_UNIQUE @@ -1511,7 +1547,7 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz /// const int kEcvtBufMaxSize = 350; -EASTDC_API char8_t* EcvtBuf(double dValue, int nDigitCount, int* pDecimalPos, int* pSign, char8_t* pBuffer); +EASTDC_API char* EcvtBuf(double dValue, int nDigitCount, int* pDecimalPos, int* pSign, char* pBuffer); EASTDC_API char16_t* EcvtBuf(double dValue, int nDigitCount, int* pDecimalPos, int* pSign, char16_t* pBuffer); EASTDC_API char32_t* EcvtBuf(double dValue, int nDigitCount, int* pDecimalPos, int* pSign, char32_t* pBuffer); #if EA_WCHAR_UNIQUE @@ -1531,7 +1567,7 @@ EASTDC_API char32_t* EcvtBuf(double dValue, int nDigitCount, int* pDecimalPos, i /// const int kFcvtBufMaxSize = 350; -EASTDC_API char8_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* pDecimalPos, int* pSign, char8_t* pBuffer); +EASTDC_API char* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* pDecimalPos, int* pSign, char* pBuffer); EASTDC_API char16_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* pDecimalPos, int* pSign, char16_t* pBuffer); EASTDC_API char32_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* pDecimalPos, int* pSign, char32_t* pBuffer); #if EA_WCHAR_UNIQUE @@ -1554,7 +1590,7 @@ const int kUint64MinCapacity = 21; /// /// Buffer must hold at least kInt32MinCapacity (12) chars. /// -EASTDC_API char8_t* I32toa(int32_t nValue, char8_t* pBuffer, int nBase); +EASTDC_API char* I32toa(int32_t nValue, char* pBuffer, int nBase); EASTDC_API char16_t* I32toa(int32_t nValue, char16_t* pBuffer, int nBase); EASTDC_API char32_t* I32toa(int32_t nValue, char32_t* pBuffer, int nBase); #if EA_WCHAR_UNIQUE @@ -1566,7 +1602,7 @@ EASTDC_API char32_t* I32toa(int32_t nValue, char32_t* pBuffer, int nBase); /// /// Buffer must hold at least kUint32MinCapacity (11) chars. /// -EASTDC_API char8_t* U32toa(uint32_t nValue, char8_t* pBuffer, int nBase); +EASTDC_API char* U32toa(uint32_t nValue, char* pBuffer, int nBase); EASTDC_API char16_t* U32toa(uint32_t nValue, char16_t* pBuffer, int nBase); EASTDC_API char32_t* U32toa(uint32_t nValue, char32_t* pBuffer, int nBase); #if EA_WCHAR_UNIQUE @@ -1578,7 +1614,7 @@ EASTDC_API char32_t* U32toa(uint32_t nValue, char32_t* pBuffer, int nBase); /// /// Buffer must hold at least kInt64MinCapacity (21) chars. /// -EASTDC_API char8_t* I64toa(int64_t nValue, char8_t* pBuffer, int nBase); +EASTDC_API char* I64toa(int64_t nValue, char* pBuffer, int nBase); EASTDC_API char16_t* I64toa(int64_t nValue, char16_t* pBuffer, int nBase); EASTDC_API char32_t* I64toa(int64_t nValue, char32_t* pBuffer, int nBase); #if EA_WCHAR_UNIQUE @@ -1590,7 +1626,7 @@ EASTDC_API char32_t* I64toa(int64_t nValue, char32_t* pBuffer, int nBase); /// /// Buffer must hold at least kUint64MinCapacity (21) chars. /// -EASTDC_API char8_t* U64toa(uint64_t nValue, char8_t* pBuffer, int nBase); +EASTDC_API char* U64toa(uint64_t nValue, char* pBuffer, int nBase); EASTDC_API char16_t* U64toa(uint64_t nValue, char16_t* pBuffer, int nBase); EASTDC_API char32_t* U64toa(uint64_t nValue, char32_t* pBuffer, int nBase); #if EA_WCHAR_UNIQUE @@ -1625,14 +1661,14 @@ EASTDC_API char32_t* U64toa(uint64_t nValue, char32_t* pBuffer, int nBase); /// /// This function has the same effect as Strtod(pString, NULL); /// -EASTDC_API double Strtod(const char8_t* pString, char8_t** ppStringEnd); +EASTDC_API double Strtod(const char* pString, char** ppStringEnd); EASTDC_API double Strtod(const char16_t* pString, char16_t** ppStringEnd); EASTDC_API double Strtod(const char32_t* pString, char32_t** ppStringEnd); #if EA_WCHAR_UNIQUE EASTDC_API double Strtod(const wchar_t* pString, wchar_t** ppStringEnd); #endif -EASTDC_API float StrtoF32(const char8_t* pString, char8_t** ppStringEnd); +EASTDC_API float StrtoF32(const char* pString, char** ppStringEnd); EASTDC_API float StrtoF32(const char16_t* pString, char16_t** ppStringEnd); EASTDC_API float StrtoF32(const char32_t* pString, char32_t** ppStringEnd); #if EA_WCHAR_UNIQUE @@ -1646,14 +1682,14 @@ EASTDC_API float StrtoF32(const char32_t* pString, char32_t** ppStringEnd); /// setting is. This is useful for being able to interpret numbers /// in a constant way with respect to decimal point usage, etc. /// -EASTDC_API double StrtodEnglish(const char8_t* pString, char8_t** ppStringEnd); +EASTDC_API double StrtodEnglish(const char* pString, char** ppStringEnd); EASTDC_API double StrtodEnglish(const char16_t* pString, char16_t** ppStringEnd); EASTDC_API double StrtodEnglish(const char32_t* pString, char32_t** ppStringEnd); #if EA_WCHAR_UNIQUE EASTDC_API double StrtodEnglish(const wchar_t* pString, wchar_t** ppStringEnd); #endif -EASTDC_API float StrtoF32English(const char8_t* pString, char8_t** ppStringEnd); +EASTDC_API float StrtoF32English(const char* pString, char** ppStringEnd); EASTDC_API float StrtoF32English(const char16_t* pString, char16_t** ppStringEnd); EASTDC_API float StrtoF32English(const char32_t* pString, char32_t** ppStringEnd); #if EA_WCHAR_UNIQUE @@ -1665,7 +1701,7 @@ EASTDC_API float StrtoF32English(const char32_t* pString, char32_t** ppStringEn /// /// It is similar to the C strtol function. /// -EASTDC_API int32_t StrtoI32(const char8_t* pString, char8_t** ppStringEnd, int nBase); +EASTDC_API int32_t StrtoI32(const char* pString, char** ppStringEnd, int nBase); EASTDC_API int32_t StrtoI32(const char16_t* pString, char16_t** ppStringEnd, int nBase); EASTDC_API int32_t StrtoI32(const char32_t* pString, char32_t** ppStringEnd, int nBase); #if EA_WCHAR_UNIQUE @@ -1677,7 +1713,7 @@ EASTDC_API int32_t StrtoI32(const char32_t* pString, char32_t** ppStringEnd, int /// /// It is similar to the C strtoul function. /// -EASTDC_API uint32_t StrtoU32(const char8_t* pString, char8_t** ppStringEnd, int nBase); +EASTDC_API uint32_t StrtoU32(const char* pString, char** ppStringEnd, int nBase); EASTDC_API uint32_t StrtoU32(const char16_t* pString, char16_t** ppStringEnd, int nBase); EASTDC_API uint32_t StrtoU32(const char32_t* pString, char32_t** ppStringEnd, int nBase); #if EA_WCHAR_UNIQUE @@ -1706,7 +1742,7 @@ EASTDC_API uint32_t StrtoU32(const char32_t* pString, char32_t** ppStringEnd, in /// StrtoI64 allows a plus (+) or minus (-) sign prefix; a leading minus sign indicates /// that the return value is negated. /// -EASTDC_API int64_t StrtoI64(const char8_t* pString, char8_t** ppStringEnd, int nBase); +EASTDC_API int64_t StrtoI64(const char* pString, char** ppStringEnd, int nBase); EASTDC_API int64_t StrtoI64(const char16_t* pString, char16_t** ppStringEnd, int nBase); EASTDC_API int64_t StrtoI64(const char32_t* pString, char32_t** ppStringEnd, int nBase); #if EA_WCHAR_UNIQUE @@ -1718,7 +1754,7 @@ EASTDC_API int64_t StrtoI64(const char32_t* pString, char32_t** ppStringEnd, int /// /// It is similar to the C strtoull function. /// -EASTDC_API uint64_t StrtoU64(const char8_t* pString, char8_t** ppStringEnd, int nBase); +EASTDC_API uint64_t StrtoU64(const char* pString, char** ppStringEnd, int nBase); EASTDC_API uint64_t StrtoU64(const char16_t* pString, char16_t** ppStringEnd, int nBase); EASTDC_API uint64_t StrtoU64(const char32_t* pString, char32_t** ppStringEnd, int nBase); #if EA_WCHAR_UNIQUE @@ -1731,7 +1767,7 @@ EASTDC_API uint64_t StrtoU64(const char32_t* pString, char32_t** ppStringEnd, in /// This function has the same effect as StrtoI32(pString, NULL, 10); /// It is similar to the C atoll function. /// -EASTDC_API int32_t AtoI32(const char8_t* pString); +EASTDC_API int32_t AtoI32(const char* pString); EASTDC_API int32_t AtoI32(const char16_t* pString); EASTDC_API int32_t AtoI32(const char32_t* pString); #if EA_WCHAR_UNIQUE @@ -1744,7 +1780,7 @@ EASTDC_API int32_t AtoI32(const char32_t* pString); /// This function has the same effect as StrtoU32(pString, NULL, 10); /// It is similar to the C atoul function. /// -EASTDC_API uint32_t AtoU32(const char8_t* pString); +EASTDC_API uint32_t AtoU32(const char* pString); EASTDC_API uint32_t AtoU32(const char16_t* pString); EASTDC_API uint32_t AtoU32(const char32_t* pString); #if EA_WCHAR_UNIQUE @@ -1756,7 +1792,7 @@ EASTDC_API uint32_t AtoU32(const char32_t* pString); /// This function has the same effect as StrtoI64(pString, NULL, 10); /// It is similar to the C atoll function. /// -EASTDC_API int64_t AtoI64(const char8_t* pString); +EASTDC_API int64_t AtoI64(const char* pString); EASTDC_API int64_t AtoI64(const char16_t* pString); EASTDC_API int64_t AtoI64(const char32_t* pString); #if EA_WCHAR_UNIQUE @@ -1769,7 +1805,7 @@ EASTDC_API int64_t AtoI64(const char32_t* pString); /// This function has the same effect as StrtoU64(pString, NULL, 10); /// It is similar to the C atoull function. /// -EASTDC_API uint64_t AtoU64(const char8_t* pString); +EASTDC_API uint64_t AtoU64(const char* pString); EASTDC_API uint64_t AtoU64(const char16_t* pString); EASTDC_API uint64_t AtoU64(const char32_t* pString); #if EA_WCHAR_UNIQUE @@ -1809,14 +1845,14 @@ EASTDC_API uint64_t AtoU64(const char32_t* pString); /// /// This function has the same effect as Strtod(pString, NULL); /// -EASTDC_API double Atof(const char8_t* pString); +EASTDC_API double Atof(const char* pString); EASTDC_API double Atof(const char16_t* pString); EASTDC_API double Atof(const char32_t* pString); #if EA_WCHAR_UNIQUE EASTDC_API double Atof(const wchar_t* pString); #endif -EASTDC_API float AtoF32(const char8_t* pString); +EASTDC_API float AtoF32(const char* pString); EASTDC_API float AtoF32(const char16_t* pString); EASTDC_API float AtoF32(const char32_t* pString); #if EA_WCHAR_UNIQUE @@ -1833,14 +1869,14 @@ EASTDC_API float AtoF32(const char32_t* pString); /// what the C runtime library language setting is. This is useful for being able to /// interpret numbers in a constant way with respect to decimal point usage, etc. /// -EASTDC_API double AtofEnglish(const char8_t* pString); +EASTDC_API double AtofEnglish(const char* pString); EASTDC_API double AtofEnglish(const char16_t* pString); EASTDC_API double AtofEnglish(const char32_t* pString); #if EA_WCHAR_UNIQUE EASTDC_API double AtofEnglish(const wchar_t* pString); #endif -EASTDC_API float AtoF32English(const char8_t* pString); +EASTDC_API float AtoF32English(const char* pString); EASTDC_API float AtoF32English(const char16_t* pString); EASTDC_API float AtoF32English(const char32_t* pString); #if EA_WCHAR_UNIQUE @@ -1865,7 +1901,7 @@ EASTDC_API float AtoF32English(const char32_t* pString); /// pResult should generally have at least 32 characters to deal with all /// floating point values. /// -EASTDC_API char8_t* Ftoa(double dValue, char8_t* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled); +EASTDC_API char* Ftoa(double dValue, char* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled); EASTDC_API char16_t* Ftoa(double dValue, char16_t* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled); EASTDC_API char32_t* Ftoa(double dValue, char32_t* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled); #if EA_WCHAR_UNIQUE @@ -1919,7 +1955,7 @@ EASTDC_API char32_t* Ftoa(double dValue, char32_t* pResult, int nResultCapacity, /// FtoaEnglish(.123450000, pResult, 20, 20, false); /// returns pResult and "0.12345" /// -EASTDC_API char8_t* FtoaEnglish(double dValue, char8_t* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled); +EASTDC_API char* FtoaEnglish(double dValue, char* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled); EASTDC_API char16_t* FtoaEnglish(double dValue, char16_t* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled); EASTDC_API char32_t* FtoaEnglish(double dValue, char32_t* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled); #if EA_WCHAR_UNIQUE @@ -1959,7 +1995,7 @@ EASTDC_API char32_t* FtoaEnglish(double dValue, char32_t* pResult, int nResultCa /// "23.43e10" /// "15e-0" /// -EASTDC_API size_t ReduceFloatString(char8_t* pString, size_t nLength = kSizeTypeUnset); +EASTDC_API size_t ReduceFloatString(char* pString, size_t nLength = kSizeTypeUnset); EASTDC_API size_t ReduceFloatString(char16_t* pString, size_t nLength = kSizeTypeUnset); EASTDC_API size_t ReduceFloatString(char32_t* pString, size_t nLength = kSizeTypeUnset); #if EA_WCHAR_UNIQUE @@ -1982,7 +2018,7 @@ namespace EA namespace StdC { - inline EASTDC_API int32_t AtoI32(const char8_t* pString) + inline EASTDC_API int32_t AtoI32(const char* pString) { return StrtoI32(pString, NULL, 10); } @@ -1999,7 +2035,7 @@ namespace StdC - inline EASTDC_API uint32_t AtoU32(const char8_t* pString) + inline EASTDC_API uint32_t AtoU32(const char* pString) { return StrtoU32(pString, NULL, 10); } @@ -2016,7 +2052,7 @@ namespace StdC - inline EASTDC_API int64_t AtoI64(const char8_t* pString) + inline EASTDC_API int64_t AtoI64(const char* pString) { return StrtoI64(pString, NULL, 10); } @@ -2033,7 +2069,7 @@ namespace StdC - inline EASTDC_API uint64_t AtoU64(const char8_t* pString) + inline EASTDC_API uint64_t AtoU64(const char* pString) { return StrtoU64(pString, NULL, 10); } @@ -2050,7 +2086,7 @@ namespace StdC - inline EASTDC_API double Strtod(const char8_t* pString, char8_t** ppStringEnd) + inline EASTDC_API double Strtod(const char* pString, char** ppStringEnd) { return strtod(pString, ppStringEnd); // strtod is well-implemented by most standard libraries. } @@ -2068,15 +2104,15 @@ namespace StdC // which makes wchar_t be 16 bit. But the GCC standard library linked in is still the one with // 32 bit wchar_t. So we can't call wcstod here as it will treat our char16_t string as a 32 bit string. // It's possible that the user could recompile libc to use 16 bit strings, but that's a pain for most users. - char8_t buffer8[64]; - char8_t* p = buffer8; - char8_t* pEnd = buffer8 + 63; + char buffer8[64]; + char* p = buffer8; + char* pEnd = buffer8 + 63; while(p != pEnd) { // '+' 'z' if((*pString < 0x2b) || (*pString > 0x7a)) // This includes a '\0' check. break; - *p++ = (char8_t)(int16_t)(uint16_t)*pString++; + *p++ = (char)(int16_t)(uint16_t)*pString++; } *p = 0; @@ -2093,16 +2129,16 @@ namespace StdC #if (EA_WCHAR_SIZE == 4) && defined(EA_HAVE_WCHAR_IMPL) return wcstod(reinterpret_cast(pString), reinterpret_cast(ppStringEnd)); #else - // We convert from char32_t to char8_t and convert that. - char8_t buffer8[64]; buffer8[0] = 0; - char8_t* p = buffer8; - char8_t* pEnd = buffer8 + 63; + // We convert from char32_t to char and convert that. + char buffer8[64]; buffer8[0] = 0; + char* p = buffer8; + char* pEnd = buffer8 + 63; while(p != pEnd) { // '+' 'z' if((*pString < 0x2b) || (*pString > 0x7a)) // This includes a '\0' check. break; - *p++ = (char8_t)(int32_t)(uint32_t)*pString++; + *p++ = (char)(int32_t)(uint32_t)*pString++; } *p = 0; @@ -2116,7 +2152,7 @@ namespace StdC - inline EASTDC_API float StrtoF32(const char8_t* pString, char8_t** ppStringEnd) + inline EASTDC_API float StrtoF32(const char* pString, char** ppStringEnd) { return (float)strtod(pString, ppStringEnd); // strtod is well-implemented by most standard libraries. } @@ -2134,7 +2170,7 @@ namespace StdC - inline EASTDC_API float StrtoF32English(const char8_t* pString, char8_t** ppStringEnd) + inline EASTDC_API float StrtoF32English(const char* pString, char** ppStringEnd) { return (float)StrtodEnglish(pString, ppStringEnd); } @@ -2151,7 +2187,7 @@ namespace StdC - inline EASTDC_API double Atof(const char8_t* pString) + inline EASTDC_API double Atof(const char* pString) { return atof(pString); // atof is well-implemented by most standard libraries. } @@ -2168,7 +2204,7 @@ namespace StdC - inline EASTDC_API float AtoF32(const char8_t* pString) + inline EASTDC_API float AtoF32(const char* pString) { return (float)atof(pString); // atof is well-implemented by most standard libraries. } @@ -2185,7 +2221,7 @@ namespace StdC - inline EASTDC_API double AtofEnglish(const char8_t* pString) + inline EASTDC_API double AtofEnglish(const char* pString) { return StrtodEnglish(pString, NULL); } @@ -2202,7 +2238,7 @@ namespace StdC - inline EASTDC_API float AtoF32English(const char8_t* pString) + inline EASTDC_API float AtoF32English(const char* pString) { return (float)StrtodEnglish(pString, NULL); } @@ -2219,7 +2255,7 @@ namespace StdC - inline EASTDC_API char8_t* Ftoa(double dValue, char8_t* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled) + inline EASTDC_API char* Ftoa(double dValue, char* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled) { // An implementation which calls sprintf might be a better idea. return FtoaEnglish(dValue, pResult, nResultCapacity, nPrecision, bExponentEnabled); @@ -2313,7 +2349,7 @@ namespace StdC return Strlcpy(EASTDC_UNICODE_CHAR_PTR_CAST(pDestination), EASTDC_UNICODE_CONST_CHAR_PTR_CAST(pSource), nDestCapacity); } - inline int Strlcpy(wchar_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength) + inline int Strlcpy(wchar_t* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength) { return static_cast(Strlcpy(EASTDC_UNICODE_CHAR_PTR_CAST(pDestination), pSource, nDestCapacity, nSourceLength)); } @@ -2338,7 +2374,7 @@ namespace StdC #endif } - inline int Strlcpy(char8_t* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength) + inline int Strlcpy(char* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength) { return static_cast(Strlcpy(pDestination, EASTDC_UNICODE_CONST_CHAR_PTR_CAST(pSource), nDestCapacity, nSourceLength)); } @@ -2363,7 +2399,7 @@ namespace StdC #endif } - inline bool Strlcpy(char8_t* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) + inline bool Strlcpy(char* pDestination, const wchar_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) { return Strlcpy(pDestination, EASTDC_UNICODE_CONST_CHAR_PTR_CAST(pSource), nDestCapacity, nSourceLength, nDestUsed, nSourceUsed); } @@ -2390,7 +2426,7 @@ namespace StdC #endif } - inline bool Strlcpy(wchar_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) + inline bool Strlcpy(wchar_t* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) { return Strlcpy(EASTDC_UNICODE_CHAR_PTR_CAST(pDestination), pSource, nDestCapacity, nSourceLength, nDestUsed, nSourceUsed); } @@ -2437,7 +2473,7 @@ namespace StdC return Strlcat(EASTDC_UNICODE_CHAR_PTR_CAST(pDestination), EASTDC_UNICODE_CONST_CHAR_PTR_CAST(pSource), nDestCapacity); } - inline size_t Strlcat(wchar_t* pDestination, const char8_t* pSource, size_t nDestCapacity) + inline size_t Strlcat(wchar_t* pDestination, const char* pSource, size_t nDestCapacity) { return Strlcat(EASTDC_UNICODE_CHAR_PTR_CAST(pDestination), pSource, nDestCapacity); } @@ -2452,7 +2488,7 @@ namespace StdC return Strlcat(EASTDC_UNICODE_CHAR_PTR_CAST(pDestination), pSource, nDestCapacity); } - inline size_t Strlcat(char8_t* pDestination, const wchar_t* pSource, size_t nDestCapacity) + inline size_t Strlcat(char* pDestination, const wchar_t* pSource, size_t nDestCapacity) { return Strlcat(pDestination, EASTDC_UNICODE_CONST_CHAR_PTR_CAST(pSource), nDestCapacity); } @@ -2784,6 +2820,11 @@ namespace StdC #endif +#if defined(EA_CHAR8_UNIQUE) && EA_CHAR8_UNIQUE + +#endif + + /////////////////////////////////////////////////////////////////////////// // Deprecated functionality /////////////////////////////////////////////////////////////////////////// diff --git a/include/EAStdC/EATextUtil.h b/include/EAStdC/EATextUtil.h index 03525e6..ebe5d0f 100644 --- a/include/EAStdC/EATextUtil.h +++ b/include/EAStdC/EATextUtil.h @@ -28,25 +28,32 @@ namespace StdC /////////////////////////////////////////////////////////////////////////////// /// UTF8 utilities /// - EASTDC_API bool UTF8Validate(const char8_t* p, size_t nLength); - EASTDC_API char8_t* UTF8Increment(const char8_t* p, size_t n); - EASTDC_API char8_t* UTF8Decrement(const char8_t* p, size_t n); - EASTDC_API size_t UTF8Length(const char8_t* p); + EASTDC_API bool UTF8Validate(const char* p, size_t nLength); + EASTDC_API char* UTF8Increment(const char* p, size_t n); + EASTDC_API char* UTF8Decrement(const char* p, size_t n); + EASTDC_API size_t UTF8Length(const char* p); EASTDC_API size_t UTF8Length(const char16_t* p); EASTDC_API size_t UTF8Length(const char32_t* p); - EASTDC_API size_t UTF8CharSize(const char8_t* p); + EASTDC_API size_t UTF8CharSize(const char* p); EASTDC_API size_t UTF8CharSize(char16_t c); EASTDC_API size_t UTF8CharSize(char32_t c); - EASTDC_API char16_t UTF8ReadChar(const char8_t* p, const char8_t** ppEnd = NULL); - EASTDC_API char8_t* UTF8WriteChar(char8_t* p, char16_t c); - EASTDC_API char8_t* UTF8WriteChar(char8_t* p, char32_t c); - EASTDC_API size_t UTF8TrimPartialChar(char8_t* p, size_t nLength); - EASTDC_API char8_t* UTF8ReplaceInvalidChar(const char8_t* pIn, size_t nLength, char8_t* pOut, char8_t replaceWith); - inline bool UTF8IsSoloByte(char8_t c) { return ((uint8_t)c < 0x80); } - inline bool UTF8IsLeadByte(char8_t c) { return (0xc0 <= (uint8_t)c) && ((uint8_t)c <= 0xef); } // This tests for lead bytes for 2 and 3 byte UTF8 sequences, which map to char16_t code points. If we were to support 4, 5, 6 byte code sequences (char32_t code points), we'd test for <= 0xfd. - inline bool UTF8IsFollowByte(char8_t c) { return (0x80 <= (uint8_t)c) && ((uint8_t)c <= 0xbf); } // This assumes that the char is part of a valid UTF8 sequence. - - + EASTDC_API char16_t UTF8ReadChar(const char* p, const char** ppEnd = NULL); + EASTDC_API char* UTF8WriteChar(char* p, char16_t c); + EASTDC_API char* UTF8WriteChar(char* p, char32_t c); + EASTDC_API size_t UTF8TrimPartialChar(char* p, size_t nLength); + EASTDC_API char* UTF8ReplaceInvalidChar(const char* pIn, size_t nLength, char* pOut, char replaceWith); + inline bool UTF8IsSoloByte(char c) { return ((uint8_t)c < 0x80); } + inline bool UTF8IsLeadByte(char c) { return (0xc0 <= (uint8_t)c) && ((uint8_t)c <= 0xef); } // This tests for lead bytes for 2 and 3 byte UTF8 sequences, which map to char16_t code points. If we were to support 4, 5, 6 byte code sequences (char32_t code points), we'd test for <= 0xfd. + inline bool UTF8IsFollowByte(char c) { return (0x80 <= (uint8_t)c) && ((uint8_t)c <= 0xbf); } // This assumes that the char is part of a valid UTF8 sequence. + + #if EA_CHAR8_UNIQUE + // We simply forward the UTF8 overload to maintain backwards compatbility. + // Eventually, we should leverage the type system instead of UTF8 specific functions. + // + inline size_t UTF8Length(const char8_t* p) { return UTF8Length((const char*)p); } + inline char8_t* UTF8ReplaceInvalidChar(const char8_t* pIn, size_t nLength, char8_t* pOut, char8_t replaceWith) + { return (char8_t*)UTF8ReplaceInvalidChar((const char*)pIn, nLength, (char*)pOut, (char)replaceWith); } +#endif /////////////////////////////////////////////////////////////////////////////// /// WildcardMatch @@ -71,7 +78,7 @@ namespace StdC /// Multiple * and ? characters may be used. Two consecutive * characters are /// treated as if they were one. /// - EASTDC_API bool WildcardMatch(const char8_t* pString, const char8_t* pPattern, bool bCaseSensitive); + EASTDC_API bool WildcardMatch(const char* pString, const char* pPattern, bool bCaseSensitive); EASTDC_API bool WildcardMatch(const char16_t* pString, const char16_t* pPattern, bool bCaseSensitive); EASTDC_API bool WildcardMatch(const char32_t* pString, const char32_t* pPattern, bool bCaseSensitive); @@ -108,8 +115,8 @@ namespace StdC /// /// See the other version of ParseDelimitedText below for some additional documentation. /// - EASTDC_API bool ParseDelimitedText(const char8_t* pText, const char8_t* pTextEnd, char8_t cDelimiter, - const char8_t*& pToken, const char8_t*& pTokenEnd, const char8_t** ppNewText); + EASTDC_API bool ParseDelimitedText(const char* pText, const char* pTextEnd, char cDelimiter, + const char*& pToken, const char*& pTokenEnd, const char** ppNewText); EASTDC_API bool ParseDelimitedText(const char16_t* pText, const char16_t* pTextEnd, char16_t cDelimiter, const char16_t*& pToken, const char16_t*& pTokenEnd, const char16_t** ppNewText); @@ -139,7 +146,7 @@ namespace StdC /// Resulting output: /// "12345678" /// - EASTDC_API void ConvertBinaryDataToASCIIArray(const void* pBinaryData, size_t nBinaryDataLength, char8_t* pASCIIArray); + EASTDC_API void ConvertBinaryDataToASCIIArray(const void* pBinaryData, size_t nBinaryDataLength, char* pASCIIArray); EASTDC_API void ConvertBinaryDataToASCIIArray(const void* pBinaryData, size_t nBinaryDataLength, char16_t* pASCIIArray); EASTDC_API void ConvertBinaryDataToASCIIArray(const void* pBinaryData, size_t nBinaryDataLength, char32_t* pASCIIArray); @@ -161,7 +168,7 @@ namespace StdC /// Resulting output: /// { 0x12, 0x34, 0x56, 0x78 } /// - EASTDC_API bool ConvertASCIIArrayToBinaryData(const char8_t* pASCIIArray, size_t nASCIIArrayLength, void* pBinaryData); + EASTDC_API bool ConvertASCIIArrayToBinaryData(const char* pASCIIArray, size_t nASCIIArrayLength, void* pBinaryData); EASTDC_API bool ConvertASCIIArrayToBinaryData(const char16_t* pASCIIArray, size_t nASCIIArrayLength, void* pBinaryData); EASTDC_API bool ConvertASCIIArrayToBinaryData(const char32_t* pASCIIArray, size_t nASCIIArrayLength, void* pBinaryData); @@ -195,7 +202,7 @@ namespace StdC /// // Use pLine - pLineEnd /// }while(pLineNext != (buffer + 256)); /// - EASTDC_API const char8_t* GetTextLine(const char8_t* pText, const char8_t* pTextEnd, const char8_t** ppNewText); + EASTDC_API const char* GetTextLine(const char* pText, const char* pTextEnd, const char** ppNewText); EASTDC_API const char16_t* GetTextLine(const char16_t* pText, const char16_t* pTextEnd, const char16_t** ppNewText); EASTDC_API const char32_t* GetTextLine(const char32_t* pText, const char32_t* pTextEnd, const char32_t** ppNewText); @@ -268,7 +275,7 @@ namespace StdC /// while(SplitTokenDelimited(pString, kLengthNull, ',', pToken, 16, &pString)) /// printf("%s\n", pToken); /// - EASTDC_API bool SplitTokenDelimited(const char8_t* pSource, size_t nSourceLength, char8_t cDelimiter, char8_t* pToken, size_t nTokenLength, const char8_t** ppNewSource = NULL); + EASTDC_API bool SplitTokenDelimited(const char* pSource, size_t nSourceLength, char cDelimiter, char* pToken, size_t nTokenLength, const char** ppNewSource = NULL); EASTDC_API bool SplitTokenDelimited(const char16_t* pSource, size_t nSourceLength, char16_t cDelimiter, char16_t* pToken, size_t nTokenLength, const char16_t** ppNewSource = NULL); EASTDC_API bool SplitTokenDelimited(const char32_t* pSource, size_t nSourceLength, char32_t cDelimiter, char32_t* pToken, size_t nTokenLength, const char32_t** ppNewSource = NULL); @@ -301,7 +308,7 @@ namespace StdC /// " " "" "" false /// NULL "" NULL false /// - EASTDC_API bool SplitTokenSeparated(const char8_t* pSource, size_t nSourceLength, char8_t cDelimiter, char8_t* pToken, size_t nTokenLength, const char8_t** ppNewSource = NULL); + EASTDC_API bool SplitTokenSeparated(const char* pSource, size_t nSourceLength, char cDelimiter, char* pToken, size_t nTokenLength, const char** ppNewSource = NULL); EASTDC_API bool SplitTokenSeparated(const char16_t* pSource, size_t nSourceLength, char16_t cDelimiter, char16_t* pToken, size_t nTokenLength, const char16_t** ppNewSource = NULL); EASTDC_API bool SplitTokenSeparated(const char32_t* pSource, size_t nSourceLength, char32_t cDelimiter, char32_t* pToken, size_t nTokenLength, const char32_t** ppNewSource = NULL); diff --git a/include/EAStdC/internal/Config.h b/include/EAStdC/internal/Config.h index 09de38f..23cbbb9 100644 --- a/include/EAStdC/internal/Config.h +++ b/include/EAStdC/internal/Config.h @@ -32,8 +32,8 @@ /////////////////////////////////////////////////////////////////////////////// #ifndef EASTDC_VERSION - #define EASTDC_VERSION "1.26.02" - #define EASTDC_VERSION_N 12602 + #define EASTDC_VERSION "1.26.03" + #define EASTDC_VERSION_N 12603 #endif @@ -200,29 +200,6 @@ #endif -/////////////////////////////////////////////////////////////////////////////// -// EASTDC_MEMCPY16_ENABLED -// -// Defined as 0 or 1. Default is 1. -// The Memcpy(char16_t*, const char16_t*, size_t) function and Memmove -// equivalent have been deprecated. For the time being we have an option -// to control their existence. -// -#ifndef EASTDC_MEMCPY16_ENABLED - #define EASTDC_MEMCPY16_ENABLED 0 -#endif - - -/////////////////////////////////////////////////////////////////////////////// -// EASTDC_MEMCPY16_ENABLED -// -// Defined as 0 or 1. Default is 0. -// -#ifndef EASTDC_MEMCHR16_ENABLED - #define EASTDC_MEMCHR16_ENABLED 0 -#endif - - /////////////////////////////////////////////////////////////////////////////// // EASTDC_CHAR32_SUPPORT_ENABLED // diff --git a/include/EAStdC/internal/EAMemory.inl b/include/EAStdC/internal/EAMemory.inl index f8cff4b..c65bb89 100644 --- a/include/EAStdC/internal/EAMemory.inl +++ b/include/EAStdC/internal/EAMemory.inl @@ -86,67 +86,67 @@ namespace StdC } - EASTDC_EAMEMORY_DECL char8_t* Memcpy(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount) + EASTDC_EAMEMORY_DECL char* Memcpy(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount) { EA_ASSERT((pSource >= (const uint8_t*)pDestination + nByteCount) || // Verify the memory doesn't overlap. (pDestination >= (const uint8_t*)pSource + nByteCount)); // Some compilers offer __builtin_memcpy, but we haven't found it to be faster than memcpy for any platforms // and it's significantly slower than memcpy for some platform/compiler combinations (e.g. SN compiler on PS3). - return (char8_t*)memcpy(pDestination, pSource, nByteCount); + return (char*)memcpy(pDestination, pSource, nByteCount); } - EASTDC_EAMEMORY_DECL char8_t* MemcpyC(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount) + EASTDC_EAMEMORY_DECL char* MemcpyC(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount) { EA_ASSERT((pSource >= (const uint8_t*)pDestination + nByteCount) || // Verify the memory doesn't overlap. (pDestination >= (const uint8_t*)pSource + nByteCount)); - return (char8_t*)memcpy(pDestination, pSource, nByteCount); + return (char*)memcpy(pDestination, pSource, nByteCount); } - EASTDC_EAMEMORY_DECL char8_t* MemcpyS(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount) + EASTDC_EAMEMORY_DECL char* MemcpyS(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount) { EA_ASSERT((pSource >= (const uint8_t*)pDestination + nByteCount) || // Verify the memory doesn't overlap. (pDestination >= (const uint8_t*)pSource + nByteCount)); - return (char8_t*)memcpy(pDestination, pSource, nByteCount); + return (char*)memcpy(pDestination, pSource, nByteCount); } - EASTDC_EAMEMORY_DECL char8_t* Memcpy128(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount) + EASTDC_EAMEMORY_DECL char* Memcpy128(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount) { EA_ASSERT((pSource >= (const uint8_t*)pDestination + nByteCount) || // Verify the memory doesn't overlap. (pDestination >= (const uint8_t*)pSource + nByteCount)); // This is expected to work with both cacheable and uncacheable memory, // thus we can't use all alternative optimized functions that exist for memcpy. - return (char8_t*)memcpy(pDestination, pSource, nByteCount); + return (char*)memcpy(pDestination, pSource, nByteCount); } - EASTDC_EAMEMORY_DECL char8_t* Memcpy128C(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount) + EASTDC_EAMEMORY_DECL char* Memcpy128C(void* EA_RESTRICT pDestination, const void* EA_RESTRICT pSource, size_t nByteCount) { EA_ASSERT((pSource >= (const uint8_t*)pDestination + nByteCount) || // Verify the memory doesn't overlap. (pDestination >= (const uint8_t*)pSource + nByteCount)); - return (char8_t*)memcpy(pDestination, pSource, nByteCount); + return (char*)memcpy(pDestination, pSource, nByteCount); } - EASTDC_EAMEMORY_DECL char8_t* Memmove(void* pDestination, const void* pSource, size_t nByteCount) + EASTDC_EAMEMORY_DECL char* Memmove(void* pDestination, const void* pSource, size_t nByteCount) { // Some compilers offer __builtin_memmove, but we haven't found it to be faster than memcpy for any platforms // and it's significantly slower than memcpy for some platform/compiler combinations (e.g. SN compiler on PS3). - return (char8_t*)memmove(pDestination, pSource, nByteCount); + return (char*)memmove(pDestination, pSource, nByteCount); } - EASTDC_EAMEMORY_DECL char8_t* MemmoveC(void* pDestination, const void* pSource, size_t nByteCount) + EASTDC_EAMEMORY_DECL char* MemmoveC(void* pDestination, const void* pSource, size_t nByteCount) { - return (char8_t*)memmove(pDestination, pSource, nByteCount); + return (char*)memmove(pDestination, pSource, nByteCount); } } // namespace StdC diff --git a/include/EAStdC/internal/ScanfCore.h b/include/EAStdC/internal/ScanfCore.h index 695cb46..caa2ce0 100644 --- a/include/EAStdC/internal/ScanfCore.h +++ b/include/EAStdC/internal/ScanfCore.h @@ -96,7 +96,7 @@ enum Sign enum Modifier { kModifierNone, // No modifier, use the type as-is. - kModifierChar, // Use char8_t instead of int. Specified by hh in front of d, i, o, u, x, or X. + kModifierChar, // Use char instead of int. Specified by hh in front of d, i, o, u, x, or X. kModifierShort, // Use short instead of int. Specified by h in front of d, i, o, u, x, or X. kModifierInt, // This is a placeholder, as integer is the default fd for integral types. kModifierLong, // Use long instead of int. Specified by l in front of d, i, o, u, x, or X. @@ -106,7 +106,7 @@ enum Modifier kModifierPtrdiff_t, // Use ptrdiff_t argument. Specified by 't' in front of d, i, o, u, x, or X. kModifierDouble, // Use double instead of float. Specified by nothing in front of e, E, f, F, g, G for printf and l for scanf. kModifierLongDouble, // Use long double instead of double. Specified by l in front of e, E, f, F, g, G for printf and L for scanf. - kModifierWChar, // Use wide char8_t instead of char8_t. Specified by l (in front of c). + kModifierWChar, // Use wide char instead of char. Specified by l (in front of c). kModifierInt8, // Use int8_t or uint8_t. Specified by I8 in front of d, i, o, u. kModifierInt16, // Use int16_t or uint16_t. Specified by I16 in front of d, i, o, u. kModifierInt32, // Use int32_t or uint32_t. Specified by I32 in front of d, i, o, u. @@ -161,7 +161,7 @@ struct CharBitmap CharBitmap() { memset(mBits, 0, sizeof(mBits)); } - int Get(char8_t c) const + int Get(char c) const { return (int)mBits[(uint8_t)(unsigned)c >> 5] & (1 << (c & 31)); } // This isn't correct. To do this completely right for all uses of scanf, @@ -173,7 +173,7 @@ struct CharBitmap int Get(char32_t c) const // If c >= 256, we return whatever the first bit is, since it will be equal to what bits 256 - 2^32 are meant to be. { if(c < 256) return (int)mBits[(uint8_t)(unsigned)c >> 5] & (1 << (c & 31)); else return (int)(mBits[0] & 0x00000001); } - void Set(char8_t c) + void Set(char c) { mBits[(uint8_t)(unsigned)c >> 5] |= (1 << (c & 31)); } void Set(char16_t c) @@ -204,7 +204,7 @@ struct CharBitmap struct DoubleValue { - char8_t mSigStr[kMaxSignificandDigits + 1]; // String + char mSigStr[kMaxSignificandDigits + 1]; // String int16_t mSigLen; // Length of string int16_t mExponent; // Exponent value. @@ -252,10 +252,10 @@ struct FormatData struct SscanfContext8 { - const char8_t* mpSource; + const char* mpSource; int mbEndFound; - SscanfContext8(const char8_t* pSource = NULL) + SscanfContext8(const char* pSource = NULL) : mpSource(pSource), mbEndFound(0) {} @@ -300,7 +300,7 @@ int StringReader32(ReadAction readAction, int value, void* pContext); /////////////////////////////////////////////////////////////////////////////// // VscanfCore // -int VscanfCore(ReadFunction8 pReadFunction8, void* pReadFunction8Context, const char8_t* pFormat, va_list arguments); +int VscanfCore(ReadFunction8 pReadFunction8, void* pReadFunction8Context, const char* pFormat, va_list arguments); int VscanfCore(ReadFunction16 pReadFunction16, void* pReadFunction8Context, const char16_t* pFormat, va_list arguments); int VscanfCore(ReadFunction32 pReadFunction32, void* pReadFunction8Context, const char32_t* pFormat, va_list arguments); diff --git a/include/EAStdC/internal/SprintfCore.h b/include/EAStdC/internal/SprintfCore.h index 2f07033..e7fd971 100644 --- a/include/EAStdC/internal/SprintfCore.h +++ b/include/EAStdC/internal/SprintfCore.h @@ -76,7 +76,7 @@ const int kMaxWidth = kConversionBufferSize - 8; const int kMaxPrecision = kConversionBufferSize - 8; const int kNoPrecision = INT_MAX; const int kFormatError = 0; -const char8_t kStringNull8[] = { '(', 'n', 'u', 'l', 'l', ')', '\0' }; // Used if the user uses "%s" but passes NULL as the string pointer. +const char kStringNull8[] = { '(', 'n', 'u', 'l', 'l', ')', '\0' }; // Used if the user uses "%s" but passes NULL as the string pointer. const char16_t kStringNull16[] = { '(', 'n', 'u', 'l', 'l', ')', '\0' }; const char32_t kStringNull32[] = { '(', 'n', 'u', 'l', 'l', ')', '\0' }; @@ -103,7 +103,7 @@ enum Sign enum Modifier { kModifierNone, // No modifier, use the type as-is. - kModifierChar, // Use char8_t instead of int. Specified by hh in front of d, i, o, u, x, or X. + kModifierChar, // Use char instead of int. Specified by hh in front of d, i, o, u, x, or X. kModifierShort, // Use short instead of int. Specified by h in front of d, i, o, u, x, or X. kModifierInt, // This is a placeholder, as integer is the default format for integral types. kModifierLong, // Use long instead of int. Specified by l in front of d, i, o, u, x, or X. @@ -113,7 +113,7 @@ enum Modifier kModifierPtrdiff_t, // Use ptrdiff_t argument. Specified by 't' in front of d, i, o, u, x, or X. kModifierDouble, // This is a placeholder, as double is the default format for floating point types. kModifierLongDouble, // Use long double instead of double. Specified by l in front of e, E, f, g, G. - kModifierWChar, // Use wide char8_t instead of char8_t. Specified by l (in front of c). + kModifierWChar, // Use wide char instead of char. Specified by l (in front of c). kModifierInt8, // Use int8_t or uint8_t. Specified by I8 in front of d, i, o, u. kModifierInt16, // Use int16_t or uint16_t. Specified by I16 in front of d, i, o, u. kModifierInt32, // Use int32_t or uint32_t. Specified by I32 in front of d, i, o, u. @@ -177,12 +177,12 @@ struct FormatData struct SnprintfContext8 { - char8_t* mpDestination; // Start of destination data. Ptr doesn't change once it has been initialized. + char* mpDestination; // Start of destination data. Ptr doesn't change once it has been initialized. size_t mnCount; // Count written to destination so far. size_t mnMaxCount; // The max count we can write to the destination. bool mbMaxCountReached; // True if the max count has been reached. Used because multi-byte strings (e.g. UTF8) could end with mnCount < mnMaxCount. - SnprintfContext8(char8_t* pDestination = NULL, size_t nCount = 0, size_t nMaxCount = (size_t)-1) + SnprintfContext8(char* pDestination = NULL, size_t nCount = 0, size_t nMaxCount = (size_t)-1) : mpDestination(pDestination), mnCount(nCount), mnMaxCount(nMaxCount), @@ -219,7 +219,7 @@ struct SnprintfContext32 #ifdef EA_PLATFORM_ANDROID struct PlatformLogWriterContext8 { - char8_t mBuffer[512]; + char mBuffer[512]; size_t mPosition; PlatformLogWriterContext8() { mBuffer[0] = 0; mPosition = 0; } @@ -230,9 +230,9 @@ struct SnprintfContext32 #endif // Default output writers -int StringWriter8 (const char8_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState wfs); -int FILEWriter8 (const char8_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState wfs); -int PlatformLogWriter8(const char8_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState wfs); +int StringWriter8 (const char* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState wfs); +int FILEWriter8 (const char* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState wfs); +int PlatformLogWriter8(const char* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState wfs); int StringWriter16 (const char16_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext16, WriteFunctionState wfs); int FILEWriter16 (const char16_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext16, WriteFunctionState wfs); @@ -269,7 +269,7 @@ void EASprintfShutdown(); // ReadFormat // // Reads the current format into FormatData. Return value is pointer to first -// char8_t/char16_t after the format data. +// char/char16_t after the format data. // // To know how printf truly needs to work, see the ISO C 1999 standard, section 7.19.6.1. // See http://www.cplusplus.com/ref/cstdio/printf.html or http://www.opengroup.org/onlinepubs/007908799/xsh/fprintf.html @@ -286,7 +286,7 @@ const CharT* ReadFormat(const CharT* EA_RESTRICT pFormat, SprintfLocal::FormatDa /////////////////////////////////////////////////////////////////////////////// // VprintfCore // -int VprintfCore(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pWriteFunctionContext8, const char8_t* EA_RESTRICT pFormat, va_list arguments); +int VprintfCore(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pWriteFunctionContext8, const char* EA_RESTRICT pFormat, va_list arguments); int VprintfCore(WriteFunction16 pWriteFunction16, void* EA_RESTRICT pWriteFunctionContext16, const char16_t* EA_RESTRICT pFormat, va_list arguments); int VprintfCore(WriteFunction32 pWriteFunction32, void* EA_RESTRICT pWriteFunctionContext32, const char32_t* EA_RESTRICT pFormat, va_list arguments); diff --git a/source/EADateTime.cpp b/source/EADateTime.cpp index 90da3eb..9a9d9d0 100644 --- a/source/EADateTime.cpp +++ b/source/EADateTime.cpp @@ -1067,7 +1067,7 @@ namespace StdC /////////////////////////////////////////////////////////////////////// // GetTimeZoneName // - EASTDC_API bool GetTimeZoneName(char8_t* pName, bool bDaylightSavingsName) + EASTDC_API bool GetTimeZoneName(char* pName, bool bDaylightSavingsName) { #if defined(EA_PLATFORM_MICROSOFT) && defined(_MSC_VER) && (_MSC_VER >= 1400) EA_COMPILETIME_ASSERT(EASTDC_UTC_TIME_AVAILABLE == 1); diff --git a/source/EAHashString.cpp b/source/EAHashString.cpp index a12d285..bdc600e 100644 --- a/source/EAHashString.cpp +++ b/source/EAHashString.cpp @@ -32,7 +32,7 @@ EASTDC_API uint32_t DJB2(const void* pData, size_t nLength, uint32_t nInitialVal } -EASTDC_API uint32_t DJB2_String8(const char8_t* pData8, uint32_t nInitialValue, CharCase charCase) +EASTDC_API uint32_t DJB2_String8(const char* pData8, uint32_t nInitialValue, CharCase charCase) { uint32_t c; @@ -48,14 +48,14 @@ EASTDC_API uint32_t DJB2_String8(const char8_t* pData8, uint32_t nInitialValue, case kCharCaseLower: { while((c = (uint8_t)*pData8++) != 0) - nInitialValue = ((nInitialValue << 5) + nInitialValue) + Tolower((char8_t)c); + nInitialValue = ((nInitialValue << 5) + nInitialValue) + Tolower((char)c); break; } case kCharCaseUpper: { while((c = (uint8_t)*pData8++) != 0) - nInitialValue = ((nInitialValue << 5) + nInitialValue) + Toupper((char8_t)c); + nInitialValue = ((nInitialValue << 5) + nInitialValue) + Toupper((char)c); break; } } @@ -114,7 +114,7 @@ EASTDC_API uint32_t FNV1(const void* pData, size_t nLength, uint32_t nInitialVal } -EASTDC_API uint32_t FNV1_String8(const char8_t* pData8, uint32_t nInitialValue, CharCase charCase) +EASTDC_API uint32_t FNV1_String8(const char* pData8, uint32_t nInitialValue, CharCase charCase) { uint32_t c; @@ -130,14 +130,14 @@ EASTDC_API uint32_t FNV1_String8(const char8_t* pData8, uint32_t nInitialValue, case kCharCaseLower: { while((c = (uint8_t)*pData8++) != 0) - nInitialValue = (nInitialValue * 16777619) ^ Tolower((char8_t)c); + nInitialValue = (nInitialValue * 16777619) ^ Tolower((char)c); break; } case kCharCaseUpper: { while((c = (uint8_t)*pData8++) != 0) - nInitialValue = (nInitialValue * 16777619) ^ Toupper((char8_t)c); + nInitialValue = (nInitialValue * 16777619) ^ Toupper((char)c); break; } } @@ -221,7 +221,7 @@ EASTDC_API uint64_t FNV64(const void* pData, size_t nLength, uint64_t nInitialVa } -EASTDC_API uint64_t FNV64_String8(const char8_t* pData8, uint64_t nInitialValue, CharCase charCase) +EASTDC_API uint64_t FNV64_String8(const char* pData8, uint64_t nInitialValue, CharCase charCase) { uint64_t c; @@ -237,14 +237,14 @@ EASTDC_API uint64_t FNV64_String8(const char8_t* pData8, uint64_t nInitialValue, case kCharCaseLower: { while((c = (uint8_t)*pData8++) != 0) - nInitialValue = (nInitialValue * UINT64_C(1099511628211)) ^ Tolower((char8_t)c); + nInitialValue = (nInitialValue * UINT64_C(1099511628211)) ^ Tolower((char)c); break; } case kCharCaseUpper: { while((c = (uint8_t)*pData8++) != 0) - nInitialValue = (nInitialValue * UINT64_C(1099511628211)) ^ Toupper((char8_t)c); + nInitialValue = (nInitialValue * UINT64_C(1099511628211)) ^ Toupper((char)c); break; } } diff --git a/source/EAMemory.cpp b/source/EAMemory.cpp index 679f66a..8e1d9cb 100644 --- a/source/EAMemory.cpp +++ b/source/EAMemory.cpp @@ -303,9 +303,9 @@ EASTDC_API const void* Memcheck64(const void* p, uint64_t c, size_t byteCount) -EASTDC_API const char8_t* Memchr(const char8_t* p, char8_t c, size_t nCharCount) +EASTDC_API const char* Memchr(const char* p, char c, size_t nCharCount) { - for(const char8_t* p8 = (const char8_t*)p; nCharCount > 0; ++p8, --nCharCount) + for(const char* p8 = (const char*)p; nCharCount > 0; ++p8, --nCharCount) { if(*p8 == c) return p8; @@ -349,8 +349,8 @@ EASTDC_API const char32_t* Memchr32(const char32_t* pString, char32_t c, size_t EASTDC_API int Memcmp(const void* pString1, const void* pString2, size_t nCharCount) { - const char8_t* p1 = (const char8_t*)pString1; - const char8_t* p2 = (const char8_t*)pString2; + const char* p1 = (const char*)pString1; + const char* p2 = (const char*)pString2; for(; nCharCount > 0; ++p1, ++p2, --nCharCount) { @@ -949,9 +949,9 @@ EASTDC_API void MemfillSpecific(void* pDestination, const void* pSource, size_t // as is usually the case for logical integer operations. EASTDC_API bool TimingSafeMemEqual(const void* pMem1, const void* pMem2, size_t byteCount) { - const char8_t* p1 = (const char8_t*)pMem1; - const char8_t* p2 = (const char8_t*)pMem2; - char8_t mask = 0; + const char* p1 = (const char*)pMem1; + const char* p2 = (const char*)pMem2; + char mask = 0; for(; byteCount > 0; ++p1, ++p2, --byteCount) mask |= (*p1 ^ *p2); // Accumulate any differences between the memory. diff --git a/source/EAProcess.cpp b/source/EAProcess.cpp index bdedddc..277faac 100644 --- a/source/EAProcess.cpp +++ b/source/EAProcess.cpp @@ -52,7 +52,7 @@ namespace EA namespace StdC { //Used to determine if a given path is a bundle extension - const char8_t* kBundleExtensions[] = { + const char* kBundleExtensions[] = { ".app", ".bundle", ".plugin" @@ -82,11 +82,11 @@ namespace StdC #endif #if EASTDC_SETCURRENTPROCESSPATH_REQUIRED - static char8_t gCurrentProcessPath[kMaxPathLength] = { 0 }; + static char gCurrentProcessPath[kMaxPathLength] = { 0 }; #endif -EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) +EASTDC_API void SetCurrentProcessPath(const char* pPath) { #if EASTDC_SETCURRENTPROCESSPATH_REQUIRED Strlcpy(gCurrentProcessPath, pPath, EAArrayCount(gCurrentProcessPath)); @@ -120,7 +120,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) return 0; } - EASTDC_API size_t GetCurrentProcessPath(char8_t* pPath, int pathCapacity, int pathFlags) + EASTDC_API size_t GetCurrentProcessPath(char* pPath, int pathCapacity, int pathFlags) { EA_ASSERT(pathCapacity > 0); EA_UNUSED(pathCapacity); @@ -163,7 +163,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) return 0; } - EASTDC_API size_t GetCurrentProcessDirectory(char8_t* pDirectory, int pathCapacity, int pathFlags) + EASTDC_API size_t GetCurrentProcessDirectory(char* pDirectory, int pathCapacity, int pathFlags) { EA_ASSERT(pathCapacity > 0); EA_UNUSED(pathCapacity); @@ -185,7 +185,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) // Gets the application file path. The path can only be obtained for applications run // from the host PC (run by Visual Studio, Neighborhood or the -run command). - EASTDC_API size_t GetCurrentProcessPath(char8_t* pPath, int pathCapacity, int /*pathFlags*/) + EASTDC_API size_t GetCurrentProcessPath(char* pPath, int pathCapacity, int /*pathFlags*/) { EA_ASSERT(pathCapacity > 0); @@ -216,7 +216,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) { EA_ASSERT(pathCapacity > 0); - char8_t path8[kMaxPathLength]; + char path8[kMaxPathLength]; GetCurrentProcessPath(path8, EAArrayCount(path8), pathFlags); const int intendedStrlen = Strlcpy(pPath, path8, pathCapacity); @@ -228,7 +228,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) return 0; } - EASTDC_API size_t GetCurrentProcessDirectory(char8_t* pDirectory, int pathCapacity, int /*pathFlags*/) + EASTDC_API size_t GetCurrentProcessDirectory(char* pDirectory, int pathCapacity, int /*pathFlags*/) { int32_t result; if (gCurrentProcessPath[0]) @@ -263,7 +263,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) { EA_ASSERT(pathCapacity > 0); - char8_t path8[kMaxDirectoryLength]; // We don't have access to EAIO here. + char path8[kMaxDirectoryLength]; // We don't have access to EAIO here. GetCurrentProcessDirectory(path8, EAArrayCount(path8), pathFlags); const int intendedStrlen = Strlcpy(pDirectory, path8, pathCapacity); @@ -281,7 +281,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) { EA_ASSERT(pathCapacity > 0); EA_UNUSED(pathCapacity); - char8_t path8[kMaxPathLength]; + char path8[kMaxPathLength]; GetCurrentProcessPath(path8, EAArrayCount(path8), pathFlags); const int intendedStrlen = Strlcpy(pPath, path8, pathCapacity); @@ -293,7 +293,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) return 0; } - static bool IsBundleFolder(char8_t* pPath, int pathCapacity) + static bool IsBundleFolder(char* pPath, int pathCapacity) { for(size_t i = 0; i < EAArrayCount(kBundleExtensions); i++) { @@ -308,7 +308,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) // To consider: add a flag so user can specify if they want the path to the actual executable even if it is in a .extension // EG: /path/to/MyApp.extension or /path/to/MyApp.extension/MyExecutable // Currently /path/to/.extension is returned if it exists, otherwise it returns the executable path - EASTDC_API size_t GetCurrentProcessPath(char8_t* pPath, int pathCapacity, int pathFlags) + EASTDC_API size_t GetCurrentProcessPath(char* pPath, int pathCapacity, int pathFlags) { EA_ASSERT(pathCapacity > 0); @@ -321,14 +321,14 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) if(result == 0) { EA_ASSERT(pathCapacity >= kMaxPathLength); - char8_t absolutePath[PATH_MAX]; + char absolutePath[PATH_MAX]; if(realpath(pPath, absolutePath) != NULL) // Obtain canonicalized absolute pathname. { if(pathFlags & kPathFlagBundlePath) { // We recursively call dirname() until we find .extension - char8_t appPath[kMaxPathLength]; + char appPath[kMaxPathLength]; EA::StdC::Strlcpy(appPath, absolutePath, kMaxPathLength); bool found = IsBundleFolder(appPath, kMaxPathLength); @@ -360,7 +360,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) { EA_ASSERT(pathCapacity > 0); EA_UNUSED(pathCapacity); - char8_t path8[kMaxDirectoryLength]; // We don't have access to EAIO here. + char path8[kMaxDirectoryLength]; // We don't have access to EAIO here. GetCurrentProcessDirectory(path8, EAArrayCount(path8), pathFlags); const int intendedStrlen = Strlcpy(pDirectory, path8, pathCapacity); @@ -372,7 +372,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) return 0; } - EASTDC_API size_t GetCurrentProcessDirectory(char8_t* pDirectory, int pathCapacity, int pathFlags) + EASTDC_API size_t GetCurrentProcessDirectory(char* pDirectory, int pathCapacity, int pathFlags) { EA_ASSERT(pathCapacity > 0); @@ -393,7 +393,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) if(intendedStrlen < (size_t)pathCapacity) // If succeeded... { - for(char8_t* p = pDirectory + intendedStrlen; p > pDirectory; --p) + for(char* p = pDirectory + intendedStrlen; p > pDirectory; --p) { if(p[-1] == '/') { @@ -417,7 +417,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) #elif defined(EA_PLATFORM_LINUX) - EASTDC_API size_t GetCurrentProcessPath(char8_t* pPath, int pathCapacity, int /*pathFlags*/) + EASTDC_API size_t GetCurrentProcessPath(char* pPath, int pathCapacity, int /*pathFlags*/) { EA_ASSERT(pathCapacity > 0); EA_UNUSED(pathCapacity); @@ -439,7 +439,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) { EA_ASSERT(pathCapacity > 0); EA_UNUSED(pathCapacity); - char8_t path8[kMaxPathLength]; + char path8[kMaxPathLength]; GetCurrentProcessPath(path8, EAArrayCount(path8), pathFlags); const int intendedStrlen = Strlcpy(pPath, path8, pathCapacity); @@ -451,7 +451,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) return 0; } - EASTDC_API size_t GetCurrentProcessDirectory(char8_t* pDirectory, int pathCapacity, int /*pathFlags*/) + EASTDC_API size_t GetCurrentProcessDirectory(char* pDirectory, int pathCapacity, int /*pathFlags*/) { EA_ASSERT(pathCapacity > 0); EA_UNUSED(pathCapacity); @@ -478,7 +478,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) { EA_ASSERT(pathCapacity > 0); EA_UNUSED(pathCapacity); - char8_t path8[kMaxDirectoryLength]; // We don't have access to EAIO here. + char path8[kMaxDirectoryLength]; // We don't have access to EAIO here. GetCurrentProcessDirectory(path8, EAArrayCount(path8), pathFlags); const int intendedStrlen = Strlcpy(pDirectory, path8, pathCapacity); @@ -561,7 +561,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) { EA_ASSERT(pathCapacity > 0); - char8_t path8[kMaxPathLength]; + char path8[kMaxPathLength]; GetCurrentProcessPath(path8, EAArrayCount(path8), pathFlags); const int intendedStrlen = Strlcpy(pPath, path8, (size_t)pathCapacity); @@ -573,7 +573,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) return 0; } - EASTDC_API size_t GetCurrentProcessPath(char8_t* pPath, int pathCapacity, int /*pathFlags*/) + EASTDC_API size_t GetCurrentProcessPath(char* pPath, int pathCapacity, int /*pathFlags*/) { EA_ASSERT(pathCapacity > 0); @@ -592,7 +592,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) EASTDC_API size_t GetCurrentProcessDirectory(char16_t* pDirectory, int pathCapacity, int pathFlags) { - char8_t dir8[kMaxDirectoryLength]; + char dir8[kMaxDirectoryLength]; GetCurrentProcessDirectory(dir8, EAArrayCount(dir8), pathFlags); const int intendedStrlen = Strlcpy(pDirectory, dir8, (size_t)pathCapacity); @@ -604,7 +604,7 @@ EASTDC_API void SetCurrentProcessPath(const char8_t* pPath) return 0; } - EASTDC_API size_t GetCurrentProcessDirectory(char8_t* pDirectory, int pathCapacity, int pathFlags) + EASTDC_API size_t GetCurrentProcessDirectory(char* pDirectory, int pathCapacity, int pathFlags) { EA_ASSERT(pathCapacity > 0); @@ -638,7 +638,7 @@ EASTDC_API size_t GetCurrentProcessPath(char32_t* pPath, int pathCapacity, int p { EA_ASSERT(pathCapacity > 0); EA_UNUSED(pathCapacity); - char8_t path8[kMaxPathLength]; + char path8[kMaxPathLength]; GetCurrentProcessPath(path8, EAArrayCount(path8), pathFlags); const int intendedStrlen = Strlcpy(pPath, path8, (size_t)pathCapacity); @@ -654,7 +654,7 @@ EASTDC_API size_t GetCurrentProcessDirectory(char32_t* pDirectory, int pathCapac { EA_ASSERT(pathCapacity > 0); EA_UNUSED(pathCapacity); - char8_t path8[kMaxDirectoryLength]; // We don't have access to EAIO here. + char path8[kMaxDirectoryLength]; // We don't have access to EAIO here. GetCurrentProcessDirectory(path8, EAArrayCount(path8), pathFlags); const int intendedStrlen = Strlcpy(pDirectory, path8, (size_t)pathCapacity); @@ -687,8 +687,8 @@ EASTDC_API size_t GetEnvironmentVar(const char16_t* pName, char16_t* pValue, siz return (size_t)dwLength; #else - char8_t name8[260]; - char8_t value8[260]; + char name8[260]; + char value8[260]; Strlcpy(name8, pName, 260); const size_t len = GetEnvironmentVar(name8, value8, 260); @@ -701,7 +701,7 @@ EASTDC_API size_t GetEnvironmentVar(const char16_t* pName, char16_t* pValue, siz } -EASTDC_API size_t GetEnvironmentVar(const char8_t* pName, char8_t* pValue, size_t valueCapacity) +EASTDC_API size_t GetEnvironmentVar(const char* pName, char* pValue, size_t valueCapacity) { #if defined(EA_PLATFORM_WINDOWS) && EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP) DWORD dwLength = GetEnvironmentVariableA(pName, pValue, (DWORD)valueCapacity); @@ -717,7 +717,7 @@ EASTDC_API size_t GetEnvironmentVar(const char8_t* pName, char8_t* pValue, size_ return (size_t)dwLength; #elif defined(EA_PLATFORM_UNIX) - const char8_t* const var = getenv(pName); + const char* const var = getenv(pName); if (var) return Strlcpy(pValue, var, valueCapacity); return (size_t)-1; @@ -738,10 +738,10 @@ EASTDC_API bool SetEnvironmentVar(const char16_t* pName, const char16_t* pValue) const BOOL bResult = SetEnvironmentVariableW(reinterpret_cast(pName), reinterpret_cast(pValue)); // Windows has the same behavior as us: NULL pValue removes the variable. return (bResult != 0); #else - char8_t name8[260]; + char name8[260]; Strlcpy(name8, pName, 260); - char8_t value8[260]; + char value8[260]; Strlcpy(value8, pValue, 260); return SetEnvironmentVar(name8, value8); @@ -749,7 +749,7 @@ EASTDC_API bool SetEnvironmentVar(const char16_t* pName, const char16_t* pValue) } -EASTDC_API bool SetEnvironmentVar(const char8_t* pName, const char8_t* pValue) +EASTDC_API bool SetEnvironmentVar(const char* pName, const char* pValue) { #if defined(EA_PLATFORM_WINDOWS) && EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP) const BOOL bResult = SetEnvironmentVariableA(pName, pValue); // Windows has the same behavior as us: NULL pValue removes the variable. @@ -784,14 +784,14 @@ EASTDC_API int Spawn(const char16_t* pPath, const char16_t* const* pArgumentArra EA_UNUSED(pArgumentArray); EA_UNUSED(wait); - // TODO: convert and call char8_t version + // TODO: convert and call char version EA_FAIL_MESSAGE("Spawn: Not implemented for this platform."); return -1; #endif } -EASTDC_API int Spawn(const char8_t* pPath, const char8_t* const* pArgumentArray, bool wait) +EASTDC_API int Spawn(const char* pPath, const char* const* pArgumentArray, bool wait) { #if defined(EA_PLATFORM_WINDOWS) && EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP) if(wait) @@ -840,7 +840,7 @@ EASTDC_API int ExecuteShellCommand(const char16_t* pCommand) // Todo: verify that newlines work here and support them if not. return _wsystem(reinterpret_cast(pCommand)); // We could do this via the shell api as well. #else - char8_t command8[260]; + char command8[260]; Strlcpy(command8, pCommand, 260); return ExecuteShellCommand(command8); @@ -848,7 +848,7 @@ EASTDC_API int ExecuteShellCommand(const char16_t* pCommand) } -int ExecuteShellCommand(const char8_t* pCommand) +int ExecuteShellCommand(const char* pCommand) { #if defined(EA_PLATFORM_WINDOWS) && EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP) // Todo: verify that newlines work here and support them if not. @@ -864,7 +864,7 @@ int ExecuteShellCommand(const char8_t* pCommand) #if defined(DISABLED_____EA_PLATFORM_UNIX) // Need to implement this in a way that doesn't use EASTL or an allocator. - EASTDC_API bool SearchEnvPathWithMode(const char8_t* pathListVar, const char8_t* fileName, int mode, eastl::string8* fullPath) + EASTDC_API bool SearchEnvPathWithMode(const char* pathListVar, const char* fileName, int mode, eastl::string8* fullPath) { if (*fileName == '/' || *fileName == '\\') { @@ -921,8 +921,8 @@ EASTDC_API bool SearchEnvironmentPath(const char16_t* pFileName, char16_t* pPath return (*pPath != 0); #else - char8_t path8 [260]; - char8_t fileName8[260]; + char path8 [260]; + char fileName8[260]; Strlcpy(path8, pPath, 260); Strlcpy(fileName8, pFileName, 260); @@ -931,7 +931,7 @@ EASTDC_API bool SearchEnvironmentPath(const char16_t* pFileName, char16_t* pPath if (pEnvironmentVar) { - char8_t environmentVariable8[260]; + char environmentVariable8[260]; Strlcpy(environmentVariable8, pEnvironmentVar, 260); success = EA::StdC::SearchEnvironmentPath(fileName8, path8, environmentVariable8); @@ -945,7 +945,7 @@ EASTDC_API bool SearchEnvironmentPath(const char16_t* pFileName, char16_t* pPath } -EASTDC_API bool SearchEnvironmentPath(const char8_t* pFileName, char8_t* pPath, const char8_t* pEnvironmentVar) +EASTDC_API bool SearchEnvironmentPath(const char* pFileName, char* pPath, const char* pEnvironmentVar) { #if defined(EA_PLATFORM_WINDOWS) && EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP) if(!pEnvironmentVar) @@ -1025,7 +1025,7 @@ EASTDC_API bool SearchEnvironmentPath(const char8_t* pFileName, char8_t* pPath, return ((uintptr_t)hInstance > 32); } - EASTDC_API bool OpenFile(const char8_t* pPath) + EASTDC_API bool OpenFile(const char* pPath) { char16_t path16[260]; Strlcpy(path16, pPath, 260); @@ -1037,16 +1037,16 @@ EASTDC_API bool SearchEnvironmentPath(const char8_t* pFileName, char8_t* pPath, EASTDC_API bool OpenFile(const char16_t* pPath) { - char8_t path8[260]; + char path8[260]; Strlcpy(path8, pPath, 260); return OpenFile(path8); } - EASTDC_API bool OpenFile(const char8_t* pPath) + EASTDC_API bool OpenFile(const char* pPath) { #if defined (EA_PLATFORM_OSX) - const char8_t* args[] = + const char* args[] = { "open", pPath, diff --git a/source/EAScanf.cpp b/source/EAScanf.cpp index d34fa8c..ba11195 100644 --- a/source/EAScanf.cpp +++ b/source/EAScanf.cpp @@ -14,10 +14,10 @@ namespace StdC { /////////////////////////////////////////////////////////////////////////////// -// char8_t functions +// char functions /////////////////////////////////////////////////////////////////////////////// -EASTDC_API int Cscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, ...) +EASTDC_API int Cscanf(ReadFunction8 pReadFunction8, void* pContext, const char* pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -25,7 +25,7 @@ EASTDC_API int Cscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_ return ScanfLocal::VscanfCore(pReadFunction8, pContext, pFormat, arguments); } -EASTDC_API int Fscanf(FILE* pFile, const char8_t* pFormat, ...) +EASTDC_API int Fscanf(FILE* pFile, const char* pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -33,7 +33,7 @@ EASTDC_API int Fscanf(FILE* pFile, const char8_t* pFormat, ...) return ScanfLocal::VscanfCore(ScanfLocal::FILEReader8, pFile, pFormat, arguments); } -EASTDC_API int Scanf(const char8_t* pFormat, ...) +EASTDC_API int Scanf(const char* pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -41,7 +41,7 @@ EASTDC_API int Scanf(const char8_t* pFormat, ...) return ScanfLocal::VscanfCore(ScanfLocal::FILEReader8, stdin, pFormat, arguments); } -EASTDC_API int Sscanf(const char8_t* pDestination, const char8_t* pFormat, ...) +EASTDC_API int Sscanf(const char* pDestination, const char* pFormat, ...) { ScanfLocal::SscanfContext8 sc(pDestination); @@ -52,22 +52,22 @@ EASTDC_API int Sscanf(const char8_t* pDestination, const char8_t* pFormat, ...) } -EASTDC_API int Vcscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, va_list arguments) +EASTDC_API int Vcscanf(ReadFunction8 pReadFunction8, void* pContext, const char* pFormat, va_list arguments) { return ScanfLocal::VscanfCore(pReadFunction8, pContext, pFormat, arguments); } -EASTDC_API int Vfscanf(FILE* pFile, const char8_t* pFormat, va_list arguments) +EASTDC_API int Vfscanf(FILE* pFile, const char* pFormat, va_list arguments) { return ScanfLocal::VscanfCore(ScanfLocal::FILEReader8, pFile, pFormat, arguments); } -EASTDC_API int Vscanf(const char8_t* pFormat, va_list arguments) +EASTDC_API int Vscanf(const char* pFormat, va_list arguments) { return ScanfLocal::VscanfCore(ScanfLocal::FILEReader8, stdin, pFormat, arguments); } -EASTDC_API int Vsscanf(const char8_t* pDestination, const char8_t* pFormat, va_list arguments) +EASTDC_API int Vsscanf(const char* pDestination, const char* pFormat, va_list arguments) { ScanfLocal::SscanfContext8 sc(pDestination); diff --git a/source/EAScanfCore.cpp b/source/EAScanfCore.cpp index 0d7bea0..af33098 100644 --- a/source/EAScanfCore.cpp +++ b/source/EAScanfCore.cpp @@ -291,7 +291,7 @@ double DoubleValue::ToDouble() const // provided strtod function, which in many cases will implement such // an algorithm itself internally. - char8_t buffer[kMaxSignificandDigits + 12]; + char buffer[kMaxSignificandDigits + 12]; int i; for(i = 0; i < mSigLen; ++i) @@ -319,7 +319,7 @@ double DoubleValue::ToDouble() const while(multiplier) { - buffer[i++] = (char8_t)('0' + (e / multiplier)); + buffer[i++] = (char)('0' + (e / multiplier)); e %= multiplier; multiplier /= 10; } @@ -669,7 +669,7 @@ class VscanfUtil switch (stringTypeSize) { case 1: - *((char8_t*)pArgumentCurrent) = 0; + *((char*)pArgumentCurrent) = 0; break; case 2: @@ -750,7 +750,7 @@ class VscanfUtil // ReportScanfWarning(loss of information); #endif - *((char8_t*)pArgumentCurrent) = (char8_t)(uint8_t)(unsigned)c; + *((char*)pArgumentCurrent) = (char)(uint8_t)(unsigned)c; break; case 2: @@ -961,16 +961,16 @@ class VscanfUtil } break; - case 'c': // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char8_t, char16_t, char32_t) - case 'C': // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char8_t, char16_t, char32_t) - case 's': // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char8_t, char16_t, char32_t) - case 'S': // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char8_t, char16_t, char32_t) + case 'c': // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char, char16_t, char32_t) + case 'C': // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char, char16_t, char32_t) + case 's': // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char, char16_t, char32_t) + case 'S': // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char, char16_t, char32_t) { // Microsoft's library goes against the C and C++ standard: %s is - // not interpreted to mean char8_t string but instead is interpreted - // to be either char8_t or wchar_t depending on what the output + // not interpreted to mean char string but instead is interpreted + // to be either char or wchar_t depending on what the output // text fd is. This is non-standard but has the convenience - // of allowing users to migrate between char8_t and wchar_t usage + // of allowing users to migrate between char and wchar_t usage // more easily. So we allow EASCANF_MS_STYLE_S_FORMAT to control this. if(fd.mModifier == kModifierLong) @@ -981,9 +981,9 @@ class VscanfUtil { #if EASCANF_MS_STYLE_S_FORMAT if((c == 's') || (c == 'c')) - fd.mModifier = (sizeof(*pFormat) == sizeof(char8_t)) ? kModifierChar : kModifierWChar; + fd.mModifier = (sizeof(*pFormat) == sizeof(char)) ? kModifierChar : kModifierWChar; else - fd.mModifier = (sizeof(*pFormat) == sizeof(char8_t)) ? kModifierWChar : kModifierChar; + fd.mModifier = (sizeof(*pFormat) == sizeof(char)) ? kModifierWChar : kModifierChar; #else if((c == 's') || (c == 'c')) fd.mModifier = kModifierChar; @@ -1093,7 +1093,7 @@ class VscanfUtil else if(fd.mModifier == kModifierNone) { #if EASCANF_MS_STYLE_S_FORMAT - fd.mModifier = (sizeof(*pFormat) == sizeof(char8_t)) ? kModifierChar : kModifierWChar; + fd.mModifier = (sizeof(*pFormat) == sizeof(char)) ? kModifierChar : kModifierWChar; #else fd.mModifier = (sizeof(*pFormat) == sizeof(char16_t)) ? kModifierWChar : kModifierChar; //TODO: This condition seems odd, needs review. #endif @@ -1119,7 +1119,7 @@ class VscanfUtil } // To do: We need to read UTF8 character sequences here instead of just ascii values. - EA_ASSERT((sizeof(CharT) != sizeof(char8_t)) || ((uint8_t)(char8_t)c < 128)); // A c >= 128 refers to a UTF8 sequence, which we don't yet support. + EA_ASSERT((sizeof(CharT) != sizeof(char)) || ((uint8_t)(char)c < 128)); // A c >= 128 refers to a UTF8 sequence, which we don't yet support. while(c && (c != ']')) // Walk through the characters until we encounter a closing ']' char. Use '-' char to indicate character ranges, as in "a-d" { @@ -1468,7 +1468,7 @@ class VscanfUtil if(Isdigit((CharT)c)) { if(doubleValue.mSigLen < kMaxSignificandDigits) // If we have any more room... - doubleValue.mSigStr[doubleValue.mSigLen++] = (char8_t)c; + doubleValue.mSigStr[doubleValue.mSigLen++] = (char)c; else nExponentAdd++; // Lose significant digits but increase the exponent multiplier, so that the final result is close intended value, though chopped. @@ -1509,7 +1509,7 @@ class VscanfUtil nExponentAdd--; // Fractional digits reduce our multiplier. if((c != '0') || doubleValue.mSigLen) - doubleValue.mSigStr[doubleValue.mSigLen++] = (char8_t)c; + doubleValue.mSigStr[doubleValue.mSigLen++] = (char)c; } // Else lose the remaining fractional part. c = pReadFunction(kReadActionRead, 0, pContext); @@ -1780,9 +1780,9 @@ class VscanfUtil bool ReadFormatSpan8(FormatData& fd, int& c, ReadFunction8 pReadFunction, void* pContext, int stringTypeSize, char*& pArgumentCurrent, int& nReadCount) { - while(fd.mnWidth-- && ((c = pReadFunction(kReadActionRead, 0, pContext)) != -1) && fd.mCharBitmap.Get((char8_t)c)) + while(fd.mnWidth-- && ((c = pReadFunction(kReadActionRead, 0, pContext)) != -1) && fd.mCharBitmap.Get((char)c)) { - uint8_t c8 = (uint8_t)c; // It's easier to work with uint8_t instead of char8_t, which might be signed. + uint8_t c8 = (uint8_t)c; // It's easier to work with uint8_t instead of char, which might be signed. switch (stringTypeSize) { @@ -1806,13 +1806,13 @@ bool ReadFormatSpan8(FormatData& fd, int& c, ReadFunction8 pReadFunction, void* // We need to convert from UTF8 to UCS here. However, this can be complicated because // multiple UTF8 chars may correspond to a single UCS char. Luckily, the UTF8 format // allows us to know how many chars are in a multi-byte sequence based on the char value. - char8_t buffer[7]; + char buffer[7]; const size_t utf8Len = utf8lengthTable[c8]; char16_t c16[2]; char32_t c32[2]; int result; - buffer[0] = (char8_t)c8; + buffer[0] = (char)c8; for(size_t i = 1; i < utf8Len; ++i) { @@ -1822,7 +1822,7 @@ bool ReadFormatSpan8(FormatData& fd, int& c, ReadFunction8 pReadFunction, void* return false; ++nReadCount; - buffer[i] = (char8_t)c; + buffer[i] = (char)c; } @@ -1862,7 +1862,7 @@ bool ReadFormatSpan16(FormatData& fd, int& c, ReadFunction16 pReadFunction, void // We need to convert from UCS2 to UTF8 here. One UCS2 char may convert to // as many as six UTF8 chars (though usually no more than three). // This Strlcpy (16 to 8) can never fail. - pArgumentCurrent += Strlcpy((char8_t*)pArgumentCurrent, &c16, 7, 1); + pArgumentCurrent += Strlcpy((char*)pArgumentCurrent, &c16, 7, 1); break; case 2: @@ -1893,7 +1893,7 @@ bool ReadFormatSpan32(FormatData& fd, int& c, ReadFunction32 pReadFunction, void // We need to convert from UCS4 to UTF8 here. One UCS4 char may convert to // as many as six UTF8 chars (though usually no more than three). // This Strlcpy (32 to 8) can never fail. - pArgumentCurrent += Strlcpy((char8_t*)pArgumentCurrent, &c32, 7, 1); + pArgumentCurrent += Strlcpy((char*)pArgumentCurrent, &c32, 7, 1); break; case 2: @@ -1916,9 +1916,9 @@ typedef bool(*ReadFormatSpanFunction8)(FormatData& fd, int& c, ReadFunction8 pRe typedef bool(*ReadFormatSpanFunction16)(FormatData& fd, int& c, ReadFunction16 pReadFunction, void* pContext, int stringTypeSize, char*& pArgumentCurrent, int& nReadCount); typedef bool(*ReadFormatSpanFunction32)(FormatData& fd, int& c, ReadFunction32 pReadFunction, void* pContext, int stringTypeSize, char*& pArgumentCurrent, int& nReadCount); -int VscanfCore(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, va_list arguments) +int VscanfCore(ReadFunction8 pReadFunction8, void* pContext, const char* pFormat, va_list arguments) { - VscanfUtil scanner; + VscanfUtil scanner; return scanner.VscanfCore(pReadFunction8, ReadFormatSpan8, pContext, pFormat, arguments); } diff --git a/source/EASprintf.cpp b/source/EASprintf.cpp index c9c353c..6f3e28a 100644 --- a/source/EASprintf.cpp +++ b/source/EASprintf.cpp @@ -25,15 +25,15 @@ namespace StdC /////////////////////////////////////////////////////////////////////////////// -// char8_t +// char /////////////////////////////////////////////////////////////////////////////// -EASTDC_API int Vcprintf(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int Vcprintf(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pContext, const char* EA_RESTRICT pFormat, va_list arguments) { return SprintfLocal::VprintfCore(pWriteFunction8, pContext, pFormat, arguments); } -EASTDC_API int Vfprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int Vfprintf(FILE* EA_RESTRICT pFile, const char* EA_RESTRICT pFormat, va_list arguments) { #if EASTDC_PRINTF_DEBUG_ENABLED if((pFile == stdout) || (pFile == stderr)) @@ -46,7 +46,7 @@ EASTDC_API int Vfprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFor return SprintfLocal::VprintfCore(SprintfLocal::FILEWriter8, pFile, pFormat, arguments); } -EASTDC_API int Vprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int Vprintf(const char* EA_RESTRICT pFormat, va_list arguments) { #if EASTDC_PRINTF_DEBUG_ENABLED SprintfLocal::PlatformLogWriterContext8 context; @@ -56,12 +56,12 @@ EASTDC_API int Vprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments) #endif } -EASTDC_API int Vsprintf(char8_t* EA_RESTRICT pDestination, const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int Vsprintf(char* EA_RESTRICT pDestination, const char* EA_RESTRICT pFormat, va_list arguments) { return Vsnprintf(pDestination, (size_t)-1, pFormat, arguments); } -EASTDC_API int Vsnprintf(char8_t* EA_RESTRICT pDestination, size_t n, const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int Vsnprintf(char* EA_RESTRICT pDestination, size_t n, const char* EA_RESTRICT pFormat, va_list arguments) { SprintfLocal::SnprintfContext8 sc(pDestination, 0, pDestination ? n : 0); @@ -92,13 +92,13 @@ EASTDC_API int Vsnprintf(char8_t* EA_RESTRICT pDestination, size_t n, const char #endif } -EASTDC_API int Vscprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int Vscprintf(const char* EA_RESTRICT pFormat, va_list arguments) { // vscprintf returns the number of chars that are needed for a printf operation. return Vsnprintf(NULL, 0, pFormat, arguments); } -EASTDC_API int Vdprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int Vdprintf(const char* EA_RESTRICT pFormat, va_list arguments) { SprintfLocal::PlatformLogWriterContext8 context; return SprintfLocal::VprintfCore(SprintfLocal::PlatformLogWriter8, &context, pFormat, arguments); @@ -107,7 +107,7 @@ EASTDC_API int Vdprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments) -EASTDC_API int Cprintf(WriteFunction8 pWriteFunction, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int Cprintf(WriteFunction8 pWriteFunction, void* EA_RESTRICT pContext, const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -119,7 +119,7 @@ EASTDC_API int Cprintf(WriteFunction8 pWriteFunction, void* EA_RESTRICT pContext return result; } -EASTDC_API int Fprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int Fprintf(FILE* EA_RESTRICT pFile, const char* EA_RESTRICT pFormat, ...) { int result; @@ -142,7 +142,7 @@ EASTDC_API int Fprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pForm return result; } -EASTDC_API int Printf(const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int Printf(const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -159,7 +159,7 @@ EASTDC_API int Printf(const char8_t* EA_RESTRICT pFormat, ...) return result; } -EASTDC_API int Sprintf(char8_t* EA_RESTRICT pDestination, const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int Sprintf(char* EA_RESTRICT pDestination, const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -171,7 +171,7 @@ EASTDC_API int Sprintf(char8_t* EA_RESTRICT pDestination, const char8_t* EA_REST return result; } -EASTDC_API int Snprintf(char8_t* EA_RESTRICT pDestination, size_t n, const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int Snprintf(char* EA_RESTRICT pDestination, size_t n, const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -183,7 +183,7 @@ EASTDC_API int Snprintf(char8_t* EA_RESTRICT pDestination, size_t n, const char8 return result; } -EASTDC_API int Dprintf(const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int Dprintf(const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -451,62 +451,8 @@ EASTDC_API int Snprintf(char32_t* EA_RESTRICT pDestination, size_t n, const char // Deprecated functionality /////////////////////////////////////////////////////////////////////////// -struct Bridge8 -{ - WriteFunction8Old mpOldWriteFunction; - void* mpUserContext; -}; - -static int WriteFunctionBridge8(const char8_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState /*wfs*/) -{ - Bridge8* pBridge8 = (Bridge8*)pContext8; - return pBridge8->mpOldWriteFunction(pData, nCount, pBridge8->mpUserContext); -} - -struct Bridge16 -{ - WriteFunction16Old mpOldWriteFunction; - void* mpUserContext; -}; - -static int WriteFunctionBridge16(const char16_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext16, WriteFunctionState /*wfs*/) -{ - Bridge16* pBridge16 = (Bridge16*)pContext16; - return pBridge16->mpOldWriteFunction(pData, nCount, pBridge16->mpUserContext); -} - -EASTDC_API int Cprintf(WriteFunction8Old pWriteFunction, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, ...) -{ - va_list arguments; - va_start(arguments, pFormat); - int result = Vcprintf(pWriteFunction, pContext, pFormat, arguments); - va_end(arguments); - return result; -} - -EASTDC_API int Cprintf(WriteFunction16Old pWriteFunction, void* EA_RESTRICT pContext, const char16_t* EA_RESTRICT pFormat, ...) -{ - va_list arguments; - va_start(arguments, pFormat); - int result = Vcprintf(pWriteFunction, pContext, pFormat, arguments); - va_end(arguments); - return result; -} - -EASTDC_API int Vcprintf(WriteFunction8Old pWriteFunction8, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, va_list arguments) -{ - Bridge8 bridge8 = { pWriteFunction8, pContext }; - return SprintfLocal::VprintfCore(WriteFunctionBridge8, &bridge8, pFormat, arguments); -} - -EASTDC_API int Vcprintf(WriteFunction16Old pWriteFunction16, void* EA_RESTRICT pContext, const char16_t* EA_RESTRICT pFormat, va_list arguments) -{ - Bridge16 bridge16 = { pWriteFunction16, pContext }; - return SprintfLocal::VprintfCore(WriteFunctionBridge16, &bridge16, pFormat, arguments); -} - #if EASTDC_VSNPRINTF8_ENABLED - EASTDC_API int Vsnprintf8(char8_t* EA_RESTRICT pDestination, size_t n, const char8_t* EA_RESTRICT pFormat, va_list arguments) + EASTDC_API int Vsnprintf8(char* EA_RESTRICT pDestination, size_t n, const char* EA_RESTRICT pFormat, va_list arguments) { return Vsnprintf(pDestination, n, pFormat, arguments); } diff --git a/source/EASprintfCore.cpp b/source/EASprintfCore.cpp index 7c1dc01..627b789 100644 --- a/source/EASprintfCore.cpp +++ b/source/EASprintfCore.cpp @@ -52,7 +52,7 @@ namespace SprintfLocal { -int StringWriter8(const char8_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState /*wfs*/) +int StringWriter8(const char* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState /*wfs*/) { using namespace SprintfLocal; @@ -133,10 +133,10 @@ int StringWriter32(const char32_t* EA_RESTRICT pData, size_t nCount, void* EA_RE -int FILEWriter8(const char8_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState /*wfs*/) +int FILEWriter8(const char* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState /*wfs*/) { FILE* const pFile = (FILE*)pContext8; - const size_t nResult = fwrite(pData, sizeof(char8_t), nCount, pFile); // It's OK if nCount == 0. + const size_t nResult = fwrite(pData, sizeof(char), nCount, pFile); // It's OK if nCount == 0. if(nResult == nCount) return (int)(unsigned)nResult; return -1; @@ -165,7 +165,7 @@ int FILEWriter32(const char32_t* EA_RESTRICT pData, size_t nCount, void* EA_REST /////////////////////////////////////////////////////////////////////////////// // PlatformLogWriter8 // -int PlatformLogWriter8(const char8_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState) +int PlatformLogWriter8(const char* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8, WriteFunctionState) { #if defined(EA_PLATFORM_ANDROID) // The __android_log_write function appends a \n to every call you make to it. This is a problem for @@ -386,7 +386,7 @@ template const CharT* StringNull(); template <> -const char8_t* StringNull() { return kStringNull8; } +const char* StringNull() { return kStringNull8; } template <> const char16_t* StringNull() { return kStringNull16; } @@ -573,7 +573,7 @@ int StringFormat(int(*pWriteFunction)(const OutCharT* EA_RESTRICT pData, size_t // ReadFormat // // Reads the current format into FormatData. Return value is pointer to first -// char8_t after the format data. +// char after the format data. // // To know how printf truly needs to work, see the ISO C 1999 standard, section 7.19.6.1. // See http://www.cplusplus.com/ref/cstdio/printf.html or http://www.opengroup.org/onlinepubs/007908799/xsh/fprintf.html @@ -718,7 +718,7 @@ const CharT* ReadFormat(const CharT* EA_RESTRICT pFormat, SprintfLocal::FormatDa case 'h': if(pFormatCurrent[1] == 'h') // If the user specified %hh ... { - // Specifies that a following d, i, o, u, x, or X conversion specifier applies to a signed char or unsigned char argument (the argument will have been promoted according to the integer promotions, but its value shall be converted to signed char8_t or unsigned char8_t before printing); or that a following n conversion specifier applies to a pointer to a signed char8_t argument. + // Specifies that a following d, i, o, u, x, or X conversion specifier applies to a signed char or unsigned char argument (the argument will have been promoted according to the integer promotions, but its value shall be converted to signed char or unsigned char before printing); or that a following n conversion specifier applies to a pointer to a signed char argument. fd.mModifier = kModifierChar; c = *++pFormatCurrent; } @@ -858,20 +858,20 @@ const CharT* ReadFormat(const CharT* EA_RESTRICT pFormat, SprintfLocal::FormatDa break; - case 'c': // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char8_t, char16_t, char32_t) - case 'C': // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char8_t, char16_t, char32_t) - case 's': // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char8_t, char16_t, char32_t) - case 'S': // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char8_t, char16_t, char32_t) + case 'c': // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char, char16_t, char32_t) + case 'C': // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char, char16_t, char32_t) + case 's': // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char, char16_t, char32_t) + case 'S': // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char, char16_t, char32_t) // If the user specified zero-fill above, then it is a mistake and we // need to use spaces instead. So we restore the fallback alignment. if(fd.mAlignment == kAlignmentZeroFill) fd.mAlignment = alignmentNonZeroFill; // Microsoft's library goes against the standard: %s is - // interpreted to mean char8_t string but instead is interpreted - // to be either char8_t or wchar_t depending on what the output + // interpreted to mean char string but instead is interpreted + // to be either char or wchar_t depending on what the output // text format is. This is non-standard but has the convenience - // of allowing users to migrate between char8_t and wchar_t usage + // of allowing users to migrate between char and wchar_t usage // more easily. So we allow EASPRINTF_MS_STYLE_S_FORMAT to control this. if(fd.mModifier == kModifierShort) fd.mModifier = kModifierChar; @@ -1207,7 +1207,7 @@ CharT* WriteDouble(const SprintfLocal::FormatData& fd, double dValue, CharT* EA_ if(!((nExponent < -4) || (nExponent >= nPrecision))) { - if(!IsSameType::value) + if(!IsSameType::value) { if(nExponent >= 0) // If there are any digits to the left of the decimal... nPrecision -= (nExponent + 1); @@ -1722,8 +1722,8 @@ int VprintfCoreInternal(int(*pWriteFunction)(const CharT* EA_RESTRICT pData, siz { case 1: { - const char8_t* pBufferData8 = va_arg(arguments, char8_t*); - nWriteCount = StringFormat(pWriteFunction, pWriteFunctionContext, fd, pBuffer, pBufferData8); + const char* pBufferData8 = va_arg(arguments, char*); + nWriteCount = StringFormat(pWriteFunction, pWriteFunctionContext, fd, pBuffer, pBufferData8); if (nWriteCount < 0) goto FormatError; nWriteCountSum += nWriteCount; @@ -1764,7 +1764,7 @@ int VprintfCoreInternal(int(*pWriteFunction)(const CharT* EA_RESTRICT pData, siz { case kModifierInt8: case kModifierChar: - *(char8_t*)pCountBufferData = (char8_t)nWriteCountSum; + *(char*)pCountBufferData = (char)nWriteCountSum; break; case kModifierInt16: @@ -1848,7 +1848,7 @@ int VprintfCoreInternal(int(*pWriteFunction)(const CharT* EA_RESTRICT pData, siz { case 1: { - const char8_t c8 = (char8_t)va_arg(arguments, int); // We make the assumption here that sizeof(char16_t) is <= sizeof(int) and thus that a char16_t argument was promoted to int. + const char c8 = (char)va_arg(arguments, int); // We make the assumption here that sizeof(char16_t) is <= sizeof(int) and thus that a char16_t argument was promoted to int. pBuffer[0] = (CharT)(uint32_t)c8; pBufferData = pBuffer; nWriteCount = 1; @@ -1877,7 +1877,7 @@ int VprintfCoreInternal(int(*pWriteFunction)(const CharT* EA_RESTRICT pData, siz case '%': { - // In this case we just write a single '%' char8_t to the output. + // In this case we just write a single '%' char to the output. pBuffer[0] = '%'; pBufferData = pBuffer; nWriteCount = 1; @@ -1920,7 +1920,7 @@ int VprintfCoreInternal(int(*pWriteFunction)(const CharT* EA_RESTRICT pData, siz /////////////////////////////////////////////////////////////////////////////// // VprintfCore // -int VprintfCore(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pWriteFunctionContext8, const char8_t* EA_RESTRICT pFormat, va_list arguments) +int VprintfCore(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pWriteFunctionContext8, const char* EA_RESTRICT pFormat, va_list arguments) { return VprintfCoreInternal(pWriteFunction8, pWriteFunctionContext8, pFormat, arguments); } diff --git a/source/EASprintfOrdered.cpp b/source/EASprintfOrdered.cpp index 7d755ba..28f8307 100644 --- a/source/EASprintfOrdered.cpp +++ b/source/EASprintfOrdered.cpp @@ -42,12 +42,12 @@ static const int kSpanFormatCapacity = 16; struct Span8 { - const char8_t* mpBegin; // The first char in the span. - const char8_t* mpEnd; // One-past the last used char. + const char* mpBegin; // The first char in the span. + const char* mpEnd; // One-past the last used char. Modifier mType; // This tells us what the type of the argument is (e.g. kModifierInt). AllTypes mValue; // This stores the value, which is of type mType. - char8_t mFormat[kSpanFormatCapacity]; // The format to use (e.g. %5.3f). If empty then this is a string span. - char8_t mFormatChar; // The last char in the mFormat string. + char mFormat[kSpanFormatCapacity]; // The format to use (e.g. %5.3f). If empty then this is a string span. + char mFormatChar; // The last char in the mFormat string. int mUserIndex; // The index the user assigned to this format. Negative value if this is a string span. bool mbEscapePresent; // True if the span is a string and it has a %% sequence. We can optimize writes if we know that it doesn't. @@ -106,7 +106,7 @@ struct Span32 // This function exists for the sole purpose of passing an arbitrary argument to VprintfCore // along with an existing WriteFunction8/pWriteFunctionContext8. -static int CallVprintfCore(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pWriteFunctionContext8, const char8_t* EA_RESTRICT pFormat, ...) +static int CallVprintfCore(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pWriteFunctionContext8, const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -143,7 +143,7 @@ static int CallVprintfCore(WriteFunction32 pWriteFunction32, void* EA_RESTRICT p // Non-format segments are simply copied to the output. Format segments are written to the output // by a call to VPrintfCore each. // -static int OVprintfCore(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pWriteFunctionContext8, const char8_t* EA_RESTRICT pFormat, va_list arguments) +static int OVprintfCore(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pWriteFunctionContext8, const char* EA_RESTRICT pFormat, va_list arguments) { const int kArgCapacity = 10; // Currently only single digit ('0'-'9') order values are supported. const int kSpanCapacity = 21; // Worst case scenario of 21 spans. For example: " %2:d %7:d %1:d %6:d %3:d %5:d %4:d %0:d %8:d %9:d " or "%0:d%1:d%2:d%3:d%4:d%5:d%6:d%7:d%8:d%9:d" @@ -155,8 +155,8 @@ static int OVprintfCore(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pWrite int nFormatLength = 0; int nWriteCountSum = 0; int startIndex = 1; // This is 1 or 0, and it defaults to 1 (but may change below) in order to mean that user formats start at 1, as in "%1:d". However, we have a feature whereby we detect that the user is using %0 as the start index. - const char8_t* p; - const char8_t* pEnd; + const char* p; + const char* pEnd; int result; static_assert((EAArrayCount(spans) == kSpanCapacity) && (EAArrayCount(spanArgOrder) == kArgCapacity), "spans and spanArgOrder are not using constants for their array size."); @@ -1240,30 +1240,30 @@ static int OVprintfCore(WriteFunction32 pWriteFunction32, void* EA_RESTRICT pWri /////////////////////////////////////////////////////////////////////////////// -// char8_t +// char /////////////////////////////////////////////////////////////////////////////// -EASTDC_API int OVcprintf(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int OVcprintf(WriteFunction8 pWriteFunction8, void* EA_RESTRICT pContext, const char* EA_RESTRICT pFormat, va_list arguments) { return SprintfLocal::OVprintfCore(pWriteFunction8, pContext, pFormat, arguments); } -EASTDC_API int OVfprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int OVfprintf(FILE* EA_RESTRICT pFile, const char* EA_RESTRICT pFormat, va_list arguments) { return SprintfLocal::OVprintfCore(SprintfLocal::FILEWriter8, pFile, pFormat, arguments); } -EASTDC_API int OVprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int OVprintf(const char* EA_RESTRICT pFormat, va_list arguments) { return SprintfLocal::OVprintfCore(SprintfLocal::FILEWriter8, stdout, pFormat, arguments); } -EASTDC_API int OVsprintf(char8_t* EA_RESTRICT pDestination, const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int OVsprintf(char* EA_RESTRICT pDestination, const char* EA_RESTRICT pFormat, va_list arguments) { return OVsnprintf(pDestination, (size_t)-1, pFormat, arguments); } -EASTDC_API int OVsnprintf(char8_t* EA_RESTRICT pDestination, size_t n, const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int OVsnprintf(char* EA_RESTRICT pDestination, size_t n, const char* EA_RESTRICT pFormat, va_list arguments) { SprintfLocal::SnprintfContext8 sc(pDestination, 0, pDestination ? n : 0); @@ -1292,20 +1292,20 @@ EASTDC_API int OVsnprintf(char8_t* EA_RESTRICT pDestination, size_t n, const cha #endif } -EASTDC_API int OVscprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments) +EASTDC_API int OVscprintf(const char* EA_RESTRICT pFormat, va_list arguments) { // vscprintf returns the number of chars that are needed for a printf operation. return OVsnprintf(NULL, 0, pFormat, arguments); } -EASTDC_API int OCprintf(WriteFunction8 pWriteFunction, void* EA_RESTRICT pContext, const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int OCprintf(WriteFunction8 pWriteFunction, void* EA_RESTRICT pContext, const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); return SprintfLocal::OVprintfCore(pWriteFunction, pContext, pFormat, arguments); } -EASTDC_API int OFprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int OFprintf(FILE* EA_RESTRICT pFile, const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -1313,7 +1313,7 @@ EASTDC_API int OFprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFor return SprintfLocal::OVprintfCore(SprintfLocal::FILEWriter8, pFile, pFormat, arguments); } -EASTDC_API int OPrintf(const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int OPrintf(const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -1321,7 +1321,7 @@ EASTDC_API int OPrintf(const char8_t* EA_RESTRICT pFormat, ...) return SprintfLocal::OVprintfCore(SprintfLocal::FILEWriter8, stdout, pFormat, arguments); } -EASTDC_API int OSprintf(char8_t* EA_RESTRICT pDestination, const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int OSprintf(char* EA_RESTRICT pDestination, const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); @@ -1329,7 +1329,7 @@ EASTDC_API int OSprintf(char8_t* EA_RESTRICT pDestination, const char8_t* EA_RES return OVsnprintf(pDestination, (size_t)SprintfLocal::kNoPrecision, pFormat, arguments); } -EASTDC_API int OSnprintf(char8_t* EA_RESTRICT pDestination, size_t n, const char8_t* EA_RESTRICT pFormat, ...) +EASTDC_API int OSnprintf(char* EA_RESTRICT pDestination, size_t n, const char* EA_RESTRICT pFormat, ...) { va_list arguments; va_start(arguments, pFormat); diff --git a/source/EAStopwatch.cpp b/source/EAStopwatch.cpp index 2a840be..4410625 100644 --- a/source/EAStopwatch.cpp +++ b/source/EAStopwatch.cpp @@ -194,7 +194,7 @@ void EAStdCStopwatchSetup() // Stopwatch Frequency mnStopwatchFrequency = mnCPUFrequency; - #elif defined(EA_PLATFORM_CAPILANO) + #elif defined(EA_PLATFORM_XBOXONE) // Microsoft has stated (https://forums.xboxlive.com/AnswerPage.aspx?qid=c3fcdad5-f3e4-46d9-85f9-d337506f0d6b&tgt=1) that // QueryPerformanceCounter / QueryPerformanceFrequency map to rdtsc and they are stable throughout the life of the process. // Thus we can use QueryPerformanceFrequency to portable tell the CPU frequency for our usage of rdtsc. diff --git a/source/EAString.cpp b/source/EAString.cpp index 608d343..b6a4f41 100644 --- a/source/EAString.cpp +++ b/source/EAString.cpp @@ -56,10 +56,10 @@ namespace StdC #endif -EASTDC_API char8_t* Strcpy(char8_t* pDestination, const char8_t* pSource) +EASTDC_API char* Strcpy(char* pDestination, const char* pSource) { - const char8_t* s = pSource; - char8_t* d = pDestination; + const char* s = pSource; + char* d = pDestination; while((*d++ = *s++) != 0) {} // Do nothing. @@ -92,10 +92,10 @@ EASTDC_API char32_t* Strcpy(char32_t* pDestination, const char32_t* pSource) -EASTDC_API char8_t* Strncpy(char8_t* pDestination, const char8_t* pSource, size_t n) +EASTDC_API char* Strncpy(char* pDestination, const char* pSource, size_t n) { - const char8_t* s = pSource; - char8_t* d = pDestination; + const char* s = pSource; + char* d = pDestination; n++; while(--n) @@ -152,9 +152,9 @@ EASTDC_API char32_t* Strncpy(char32_t* pDestination, const char32_t* pSource, si -EASTDC_API char8_t* StringnCopy(char8_t* pDestination, const char8_t* pSource, size_t n) +EASTDC_API char* StringnCopy(char* pDestination, const char* pSource, size_t n) { - char8_t* pOriginalDest = pDestination; + char* pOriginalDest = pDestination; if(n) { @@ -204,7 +204,7 @@ EASTDC_API char32_t* StringnCopy(char32_t* pDestination, const char32_t* pSource /* Reference implementation which ought to be a little slower than our more optimized implementation. -EASTDC_API size_t Strlcpy(char8_t* pDestination, const char8_t* pSource, size_t nDestCapacity) +EASTDC_API size_t Strlcpy(char* pDestination, const char* pSource, size_t nDestCapacity) { const size_t n = Strlen(pSource); @@ -220,9 +220,9 @@ EASTDC_API size_t Strlcpy(char8_t* pDestination, const char8_t* pSource, size_t } */ -EASTDC_API size_t Strlcpy(char8_t* pDestination, const char8_t* pSource, size_t nDestCapacity) +EASTDC_API size_t Strlcpy(char* pDestination, const char* pSource, size_t nDestCapacity) { - const char8_t* s = pSource; + const char* s = pSource; size_t n = nDestCapacity; if(n && --n) @@ -314,7 +314,7 @@ EASTDC_API size_t Strlcpy(char32_t* pDestination, const char32_t* pSource, size_ /* // To consider: Enable this for completeness with the above: -EASTDC_API int Strlcpy(char8_t* pDest, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength) +EASTDC_API int Strlcpy(char* pDest, const char* pSource, size_t nDestCapacity, size_t nSourceLength) { if(nSourceLength == kSizeTypeUnset) nSourceLength = Strlen(pSource); @@ -444,9 +444,9 @@ static const uint32_t utf8MaximumValueTable[] = const uint32_t kUnicodeReplacementChar = 0x0000fffd; const uint32_t kUnicodeInvalidDecode = 0xffffffffu; -EA_FORCE_INLINE uint32_t DecodeCodePoint(const char8_t*& pSourceStart, const char8_t* pSourceEnd) +EA_FORCE_INLINE uint32_t DecodeCodePoint(const char*& pSourceStart, const char* pSourceEnd) { - const char8_t* pSource = pSourceStart; + const char* pSource = pSourceStart; uint32_t c = (uint8_t)*(pSource++); if(c < 128) @@ -497,21 +497,21 @@ EA_FORCE_INLINE uint32_t DecodeCodePoint(const char8_t*& pSourceStart, const cha return c; } -EA_FORCE_INLINE bool EncodeCodePoint(uint32_t c, char8_t*& pDestStart, char8_t* pDestEnd) +EA_FORCE_INLINE bool EncodeCodePoint(uint32_t c, char*& pDestStart, char* pDestEnd) { // Encode as UTF-8 if(c < 0x00000080u) { - *(pDestStart++) = static_cast(c); + *(pDestStart++) = static_cast(c); return true; } else if(c < 0x00000800u) { if (pDestStart + 2 <= pDestEnd) { - char8_t* pDest = pDestStart; - *(pDest++) = static_cast((c >> 6) | 0xc0); - *(pDest++) = static_cast((c | 0x80) & 0xbf); + char* pDest = pDestStart; + *(pDest++) = static_cast((c >> 6) | 0xc0); + *(pDest++) = static_cast((c | 0x80) & 0xbf); pDestStart = pDest; return true; } @@ -521,10 +521,10 @@ EA_FORCE_INLINE bool EncodeCodePoint(uint32_t c, char8_t*& pDestStart, char8_t* { if (pDestStart + 3 <= pDestEnd) { - char8_t* pDest = pDestStart; - *(pDest++) = static_cast((c >> 12) | 0xe0); - *(pDest++) = static_cast(((c >> 6) | 0x80) & 0xbf); - *(pDest++) = static_cast((c | 0x80) & 0xbf); + char* pDest = pDestStart; + *(pDest++) = static_cast((c >> 12) | 0xe0); + *(pDest++) = static_cast(((c >> 6) | 0x80) & 0xbf); + *(pDest++) = static_cast((c | 0x80) & 0xbf); pDestStart = pDest; return true; } @@ -534,11 +534,11 @@ EA_FORCE_INLINE bool EncodeCodePoint(uint32_t c, char8_t*& pDestStart, char8_t* { if(pDestStart + 4 <= pDestEnd) { - char8_t* pDest = pDestStart; - *(pDest++) = static_cast((c >> 18) | 0xf0); - *(pDest++) = static_cast(((c >> 12) | 0x80) & 0xbf); - *(pDest++) = static_cast(((c >> 6) | 0x80) & 0xbf); - *(pDest++) = static_cast((c | 0x80) & 0xbf); + char* pDest = pDestStart; + *(pDest++) = static_cast((c >> 18) | 0xf0); + *(pDest++) = static_cast(((c >> 12) | 0x80) & 0xbf); + *(pDest++) = static_cast(((c >> 6) | 0x80) & 0xbf); + *(pDest++) = static_cast((c | 0x80) & 0xbf); pDestStart = pDest; return true; } @@ -551,10 +551,10 @@ EA_FORCE_INLINE bool EncodeCodePoint(uint32_t c, char8_t*& pDestStart, char8_t* c = kUnicodeReplacementChar; if(pDestStart + 3 <= pDestEnd) { - char8_t* pDest = pDestStart; - *(pDest++) = static_cast((c >> 12) | 0xe0); - *(pDest++) = static_cast(((c >> 6) | 0x80) & 0xbf); - *(pDest++) = static_cast(((c >> 0) | 0x80) & 0xbf); + char* pDest = pDestStart; + *(pDest++) = static_cast((c >> 12) | 0xe0); + *(pDest++) = static_cast(((c >> 6) | 0x80) & 0xbf); + *(pDest++) = static_cast(((c >> 0) | 0x80) & 0xbf); pDestStart = pDest; return true; } @@ -623,17 +623,17 @@ bool StrlcpyInternal(OutCharT* pDest, const InCharT* pSource, size_t nDestCapaci return bGood; } -bool Strlcpy(char8_t* pDest, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) +bool Strlcpy(char* pDest, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) { return StrlcpyInternal(pDest, pSource, nDestCapacity, nSourceLength, nDestUsed, nSourceUsed); } -bool Strlcpy(char8_t* pDest, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) +bool Strlcpy(char* pDest, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) { return StrlcpyInternal(pDest, pSource, nDestCapacity, nSourceLength, nDestUsed, nSourceUsed); } -bool Strlcpy(char16_t* pDest, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) +bool Strlcpy(char16_t* pDest, const char* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) { return StrlcpyInternal(pDest, pSource, nDestCapacity, nSourceLength, nDestUsed, nSourceUsed); } @@ -643,7 +643,7 @@ bool Strlcpy(char16_t* pDest, const char32_t* pSource, size_t nDestCapacity, siz return StrlcpyInternal(pDest, pSource, nDestCapacity, nSourceLength, nDestUsed, nSourceUsed); } -bool Strlcpy(char32_t* pDest, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) +bool Strlcpy(char32_t* pDest, const char* pSource, size_t nDestCapacity, size_t nSourceLength, size_t& nDestUsed, size_t& nSourceUsed) { return StrlcpyInternal(pDest, pSource, nDestCapacity, nSourceLength, nDestUsed, nSourceUsed); } @@ -653,7 +653,7 @@ bool Strlcpy(char32_t* pDest, const char16_t* pSource, size_t nDestCapacity, siz return StrlcpyInternal(pDest, pSource, nDestCapacity, nSourceLength, nDestUsed, nSourceUsed); } -EASTDC_API int Strlcpy(char8_t* pDest, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength) +EASTDC_API int Strlcpy(char* pDest, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength) { size_t destCount = 0; @@ -668,7 +668,7 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char16_t* pSource, size_t nDestCapa break; if(pDest && ((destCount + 1) < nDestCapacity)) - *pDest++ = static_cast(c); + *pDest++ = static_cast(c); destCount += 1; } @@ -676,8 +676,8 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char16_t* pSource, size_t nDestCapa { if(pDest && ((destCount + 2) < nDestCapacity)) { - *pDest++ = static_cast((c >> 6) | 0xc0); - *pDest++ = static_cast((c | 0x80) & 0xbf); + *pDest++ = static_cast((c >> 6) | 0xc0); + *pDest++ = static_cast((c | 0x80) & 0xbf); } destCount += 2; @@ -686,9 +686,9 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char16_t* pSource, size_t nDestCapa { if(pDest && ((destCount + 3) < nDestCapacity)) { - *pDest++ = static_cast((c >> 12) | 0xe0); - *pDest++ = static_cast(((c >> 6) | 0x80) & 0xbf); - *pDest++ = static_cast((c | 0x80) & 0xbf); + *pDest++ = static_cast((c >> 12) | 0xe0); + *pDest++ = static_cast(((c >> 6) | 0x80) & 0xbf); + *pDest++ = static_cast((c | 0x80) & 0xbf); } destCount += 3; @@ -697,10 +697,10 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char16_t* pSource, size_t nDestCapa { if(pDest && ((destCount + 4) < nDestCapacity)) { - *pDest++ = static_cast((c >> 18) | 0xf0); - *pDest++ = static_cast(((c >> 12) | 0x80) & 0xbf); - *pDest++ = static_cast(((c >> 6) | 0x80) & 0xbf); - *pDest++ = static_cast((c | 0x80) & 0xbf); + *pDest++ = static_cast((c >> 18) | 0xf0); + *pDest++ = static_cast(((c >> 12) | 0x80) & 0xbf); + *pDest++ = static_cast(((c >> 6) | 0x80) & 0xbf); + *pDest++ = static_cast((c | 0x80) & 0xbf); } destCount += 4; @@ -711,9 +711,9 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char16_t* pSource, size_t nDestCapa if(pDest && ((destCount + 3) < nDestCapacity)) { - *pDest++ = static_cast( (kIllegalUnicodeChar >> 12) | 0xe0); - *pDest++ = static_cast(((kIllegalUnicodeChar >> 6) | 0x80) & 0xbf); - *pDest++ = static_cast(((kIllegalUnicodeChar >> 0) | 0x80) & 0xbf); + *pDest++ = static_cast( (kIllegalUnicodeChar >> 12) | 0xe0); + *pDest++ = static_cast(((kIllegalUnicodeChar >> 6) | 0x80) & 0xbf); + *pDest++ = static_cast(((kIllegalUnicodeChar >> 0) | 0x80) & 0xbf); } destCount += 3; @@ -726,7 +726,7 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char16_t* pSource, size_t nDestCapa return (int)(unsigned)destCount; } -EASTDC_API int Strlcpy(char8_t* pDest, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength) +EASTDC_API int Strlcpy(char* pDest, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength) { size_t destCount = 0; @@ -741,7 +741,7 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char32_t* pSource, size_t nDestCapa break; if(pDest && ((destCount + 1) < nDestCapacity)) - *pDest++ = static_cast(c); + *pDest++ = static_cast(c); destCount += 1; } @@ -749,8 +749,8 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char32_t* pSource, size_t nDestCapa { if(pDest && ((destCount + 2) < nDestCapacity)) { - *pDest++ = static_cast((c >> 6) | 0xc0); - *pDest++ = static_cast((c | 0x80) & 0xbf); + *pDest++ = static_cast((c >> 6) | 0xc0); + *pDest++ = static_cast((c | 0x80) & 0xbf); } destCount += 2; @@ -759,9 +759,9 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char32_t* pSource, size_t nDestCapa { if(pDest && ((destCount + 3) < nDestCapacity)) { - *pDest++ = static_cast((c >> 12) | 0xe0); - *pDest++ = static_cast(((c >> 6) | 0x80) & 0xbf); - *pDest++ = static_cast((c | 0x80) & 0xbf); + *pDest++ = static_cast((c >> 12) | 0xe0); + *pDest++ = static_cast(((c >> 6) | 0x80) & 0xbf); + *pDest++ = static_cast((c | 0x80) & 0xbf); } destCount += 3; @@ -770,10 +770,10 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char32_t* pSource, size_t nDestCapa { if(pDest && ((destCount + 4) < nDestCapacity)) { - *pDest++ = static_cast((c >> 18) | 0xf0); - *pDest++ = static_cast(((c >> 12) | 0x80) & 0xbf); - *pDest++ = static_cast(((c >> 6) | 0x80) & 0xbf); - *pDest++ = static_cast((c | 0x80) & 0xbf); + *pDest++ = static_cast((c >> 18) | 0xf0); + *pDest++ = static_cast(((c >> 12) | 0x80) & 0xbf); + *pDest++ = static_cast(((c >> 6) | 0x80) & 0xbf); + *pDest++ = static_cast((c | 0x80) & 0xbf); } destCount += 4; @@ -786,9 +786,9 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char32_t* pSource, size_t nDestCapa if(pDest && ((destCount + 3) < nDestCapacity)) { - *pDest++ = static_cast( (kIllegalUnicodeChar >> 12) | 0xe0); - *pDest++ = static_cast(((kIllegalUnicodeChar >> 6) | 0x80) & 0xbf); - *pDest++ = static_cast(((kIllegalUnicodeChar >> 0) | 0x80) & 0xbf); + *pDest++ = static_cast( (kIllegalUnicodeChar >> 12) | 0xe0); + *pDest++ = static_cast(((kIllegalUnicodeChar >> 6) | 0x80) & 0xbf); + *pDest++ = static_cast(((kIllegalUnicodeChar >> 0) | 0x80) & 0xbf); } destCount += 3; @@ -803,7 +803,7 @@ EASTDC_API int Strlcpy(char8_t* pDest, const char32_t* pSource, size_t nDestCapa -EASTDC_API int Strlcpy(char16_t* pDest, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength) +EASTDC_API int Strlcpy(char16_t* pDest, const char* pSource, size_t nDestCapacity, size_t nSourceLength) { size_t destCount = 0; @@ -874,7 +874,7 @@ EASTDC_API int Strlcpy(char16_t* pDest, const char8_t* pSource, size_t nDestCapa return (int)(unsigned)destCount; } -EASTDC_API int Strlcpy(char32_t* pDest, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength) +EASTDC_API int Strlcpy(char32_t* pDest, const char* pSource, size_t nDestCapacity, size_t nSourceLength) { size_t destCount = 0; @@ -995,10 +995,10 @@ EASTDC_API int Strlcpy(char16_t* pDest, const char32_t* pSource, size_t nDestCap -EASTDC_API char8_t* Strcat(char8_t* pDestination, const char8_t* pSource) +EASTDC_API char* Strcat(char* pDestination, const char* pSource) { - const char8_t* s = pSource; - char8_t* d = pDestination; + const char* s = pSource; + char* d = pDestination; while(*d++){} // Do nothing. --d; @@ -1037,10 +1037,10 @@ EASTDC_API char32_t* Strcat(char32_t* pDestination, const char32_t* pSource) -EASTDC_API char8_t* Strncat(char8_t* pDestination, const char8_t* pSource, size_t n) +EASTDC_API char* Strncat(char* pDestination, const char* pSource, size_t n) { - const char8_t* s = pSource; - char8_t* d = pDestination; + const char* s = pSource; + char* d = pDestination; while(*d++){} // Do nothing. --d; @@ -1102,9 +1102,9 @@ EASTDC_API char32_t* Strncat(char32_t* pDestination, const char32_t* pSource, si -EASTDC_API char8_t* StringnCat(char8_t* pDestination, const char8_t* pSource, size_t n) +EASTDC_API char* StringnCat(char* pDestination, const char* pSource, size_t n) { - char8_t* const pOriginalDest = pDestination; + char* const pOriginalDest = pDestination; if(n) { @@ -1159,7 +1159,7 @@ EASTDC_API char32_t* StringnCat(char32_t* pDestination, const char32_t* pSource, -EASTDC_API size_t Strlcat(char8_t* pDestination, const char8_t* pSource, size_t nDestCapacity) +EASTDC_API size_t Strlcat(char* pDestination, const char* pSource, size_t nDestCapacity) { const size_t d = nDestCapacity ? Strlen(pDestination) : 0; const size_t s = Strlen(pSource); @@ -1231,7 +1231,7 @@ EASTDC_API size_t Strlcat(char32_t* pDestination, const char32_t* pSource, size_ -EASTDC_API size_t Strlcat(char16_t* pDestination, const char8_t* pSource, size_t nDestCapacity) +EASTDC_API size_t Strlcat(char16_t* pDestination, const char* pSource, size_t nDestCapacity) { size_t sourceLen = StrlenUTF8Decoded(pSource); size_t destLen = Strlen(pDestination); @@ -1242,7 +1242,7 @@ EASTDC_API size_t Strlcat(char16_t* pDestination, const char8_t* pSource, size_t return sourceLen + destLen; } -EASTDC_API size_t Strlcat(char32_t* pDestination, const char8_t* pSource, size_t nDestCapacity) +EASTDC_API size_t Strlcat(char32_t* pDestination, const char* pSource, size_t nDestCapacity) { size_t sourceLen = StrlenUTF8Decoded(pSource); size_t destLen = Strlen(pDestination); @@ -1256,7 +1256,7 @@ EASTDC_API size_t Strlcat(char32_t* pDestination, const char8_t* pSource, size_t -EASTDC_API size_t Strlcat(char8_t* pDestination, const char16_t* pSource, size_t nDestCapacity) +EASTDC_API size_t Strlcat(char* pDestination, const char16_t* pSource, size_t nDestCapacity) { size_t sourceLen = Strlen(pSource); size_t destLen = StrlenUTF8Decoded(pDestination); @@ -1267,7 +1267,7 @@ EASTDC_API size_t Strlcat(char8_t* pDestination, const char16_t* pSource, size_t return sourceLen + destLen; } -EASTDC_API size_t Strlcat(char8_t* pDestination, const char32_t* pSource, size_t nDestCapacity) +EASTDC_API size_t Strlcat(char* pDestination, const char32_t* pSource, size_t nDestCapacity) { size_t sourceLen = Strlen(pSource); size_t destLen = StrlenUTF8Decoded(pDestination); @@ -1325,7 +1325,7 @@ EASTDC_API size_t Strlcat(char32_t* pDestination, const char16_t* pSource, size_ #if EASTDC_ENABLE_OPTIMIZED_STRLEN - EASTDC_API size_t Strlen(const char8_t* pString) + EASTDC_API size_t Strlen(const char* pString) { #if EA_COMPILER_HAS_BUILTIN(__builtin_strlen) return __builtin_strlen(pString); @@ -1333,7 +1333,7 @@ EASTDC_API size_t Strlcat(char32_t* pDestination, const char16_t* pSource, size_ // Instead of casting between types, we just create a union. union PointerUnion { - const char8_t* mp8; + const char* mp8; const word_type* mpW; uintptr_t mU; } pu; @@ -1351,7 +1351,7 @@ EASTDC_API size_t Strlcat(char32_t* pDestination, const char16_t* pSource, size_ __builtin_prefetch(pu.mpW + 64, 0, 0); #endif - // Quit if there are any zero char8_ts. + // Quit if there are any zero chars. const word_type kOneBytes = ((word_type)-1 / 0xff); // 0x01010101 const word_type kHighBytes = (kOneBytes * 0x80); // 0x80808080 @@ -1371,7 +1371,7 @@ EASTDC_API size_t Strlcat(char32_t* pDestination, const char16_t* pSource, size_ #else - EASTDC_API size_t Strlen(const char8_t* pString) + EASTDC_API size_t Strlen(const char* pString) { ssize_t nLength = (size_t)-1; // EABase 1.0.14 and later recognize ssize_t for all platforms. @@ -1462,7 +1462,7 @@ EASTDC_API size_t Strlen(const char32_t* pString) // Returns number of Unicode characters are in the UTF8-encoded string. // Return value will be <= Strlen(pString). -EASTDC_API size_t StrlenUTF8Decoded(const char8_t* pString) +EASTDC_API size_t StrlenUTF8Decoded(const char* pString) { size_t nLength = 0; @@ -1531,12 +1531,12 @@ EASTDC_API size_t StrlenUTF8Encoded(const char32_t* pString) -EASTDC_API char8_t* Strend(const char8_t* pString) +EASTDC_API char* Strend(const char* pString) { while (*pString) ++pString; - return (char8_t*)pString; + return (char*)pString; } EASTDC_API char16_t* Strend(const char16_t* pString) @@ -1557,7 +1557,7 @@ EASTDC_API char32_t* Strend(const char32_t* pString) -EASTDC_API size_t Strxfrm(char8_t* pDest, const char8_t* pSource, size_t n) +EASTDC_API size_t Strxfrm(char* pDest, const char* pSource, size_t n) { const size_t nLength = Strlen(pSource); @@ -1601,12 +1601,12 @@ EASTDC_API size_t Strxfrm(char32_t* pDest, const char32_t* pSource, size_t n) -EASTDC_API char8_t* Strdup(const char8_t* pString) +EASTDC_API char* Strdup(const char* pString) { if(pString) { const size_t nLength = Strlen(pString); - char8_t* const p = EASTDC_NEW(EASTDC_ALLOC_PREFIX "Strdup") char8_t[nLength + 1]; // '+ 1' to include terminating zero. + char* const p = EASTDC_NEW(EASTDC_ALLOC_PREFIX "Strdup") char[nLength + 1]; // '+ 1' to include terminating zero. Strcpy(p, pString); return p; @@ -1645,7 +1645,7 @@ EASTDC_API char32_t* Strdup(const char32_t* pString) -EASTDC_API void Strdel(char8_t* pString) +EASTDC_API void Strdel(char* pString) { EASTDC_DELETE[] pString; } @@ -1663,17 +1663,17 @@ EASTDC_API void Strdel(char32_t* pString) -EASTDC_API char8_t* Strupr(char8_t* pString) +EASTDC_API char* Strupr(char* pString) { // This implementation converts only 7 bit ASCII characters. // As such it is safe to use with 7-bit-safe multibyte encodings // such as UTF8 but may yield incorrect results with such text. - char8_t* pStringTemp = pString; + char* pStringTemp = pString; while(*pStringTemp) { if((uint8_t)*pStringTemp <= 127) - *pStringTemp = (char8_t)Toupper(*pStringTemp); + *pStringTemp = (char)Toupper(*pStringTemp); ++pStringTemp; } @@ -1709,17 +1709,17 @@ EASTDC_API char32_t* Strupr(char32_t* pString) -EASTDC_API char8_t* Strlwr(char8_t* pString) +EASTDC_API char* Strlwr(char* pString) { // This implementation converts only 7 bit ASCII characters. // As such it is safe to use with 7-bit-safe multibyte encodings // such as UTF8 but may yield incorrect results with such text. - char8_t* pStringTemp = pString; + char* pStringTemp = pString; while(*pStringTemp) { if((uint8_t)*pStringTemp <= 127) - *pStringTemp = (char8_t)Tolower(*pStringTemp); + *pStringTemp = (char)Tolower(*pStringTemp); ++pStringTemp; } @@ -1755,14 +1755,14 @@ EASTDC_API char32_t* Strlwr(char32_t* pString) -EASTDC_API char8_t* Strmix(char8_t* pDestination, const char8_t* pSource, const char8_t* pDelimiters) +EASTDC_API char* Strmix(char* pDestination, const char* pSource, const char* pDelimiters) { bool bCapitalize = true; - char8_t* const pOriginalDest = pDestination; + char* const pOriginalDest = pDestination; while(*pSource) { - char8_t c = *pSource++; + char c = *pSource++; // This character is upper-cased if bCapitalize flag is true, else lower-cased if(bCapitalize) @@ -1782,7 +1782,7 @@ EASTDC_API char8_t* Strmix(char8_t* pDestination, const char8_t* pSource, const } // Check whether this character is a separator character. If so, set the bCapitalize flag. - for(const char8_t* pCheck = pDelimiters; *pCheck; ++pCheck) + for(const char* pCheck = pDelimiters; *pCheck; ++pCheck) { if(c == *pCheck) bCapitalize = true; @@ -1878,12 +1878,12 @@ EASTDC_API char32_t* Strmix(char32_t* pDestination, const char32_t* pSource, con -EASTDC_API char8_t* Strchr(const char8_t* pString, int c) +EASTDC_API char* Strchr(const char* pString, int c) { do { if (*pString == c) - return (char8_t*)pString; + return (char*)pString; } while (*pString++); return NULL; @@ -1913,13 +1913,13 @@ EASTDC_API char32_t* Strchr(const char32_t* pString, char32_t c) -EASTDC_API char8_t* Strnchr(const char8_t* pString, int c, size_t n) +EASTDC_API char* Strnchr(const char* pString, int c, size_t n) { while(n-- > 0) { if(*pString == c) { - return (char8_t*)pString; + return (char*)pString; } if(*pString == '\0') { @@ -1967,16 +1967,16 @@ EASTDC_API char32_t* Strnchr(const char32_t* pString, char32_t c, size_t n) -EASTDC_API size_t Strcspn(const char8_t* pString1, const char8_t* pString2) +EASTDC_API size_t Strcspn(const char* pString1, const char* pString2) { - const char8_t* pStringCurrent = pString1; + const char* pStringCurrent = pString1; // This implementation does a double loop. As such, it can get slow for // very long strings. An alternative implementation is to use a hash // table or to create a bytemap of the chars in pString2. while(*pStringCurrent) { - for(const char8_t* pCharSet = pString2; *pCharSet; ++pCharSet) + for(const char* pCharSet = pString2; *pCharSet; ++pCharSet) { if(*pCharSet == *pStringCurrent) return (size_t)(pStringCurrent - pString1); @@ -2035,17 +2035,17 @@ EASTDC_API size_t Strcspn(const char32_t* pString1, const char32_t* pString2) -EASTDC_API char8_t* Strpbrk(const char8_t* pString1, const char8_t* pString2) +EASTDC_API char* Strpbrk(const char* pString1, const char* pString2) { // This implementation does a double loop. As such, it can get slow for // very long strings. An alternative implementation is to use a hash // table or to create a bytemap of the chars in pString2. while(*pString1) { - for(const char8_t* pCharSet = pString2; *pCharSet; ++pCharSet) + for(const char* pCharSet = pString2; *pCharSet; ++pCharSet) { if(*pCharSet == *pString1) - return (char8_t*)pString1; + return (char*)pString1; } ++pString1; @@ -2095,10 +2095,10 @@ EASTDC_API char32_t* Strpbrk(const char32_t* pString1, const char32_t* pString2) } -EASTDC_API char8_t* Strrchr(const char8_t* pString, int c) +EASTDC_API char* Strrchr(const char* pString, int c) { - const char8_t* pFound = NULL; - char8_t cCurrent; + const char* pFound = NULL; + char cCurrent; while ((cCurrent = *pString++) != 0) { @@ -2107,9 +2107,9 @@ EASTDC_API char8_t* Strrchr(const char8_t* pString, int c) } if (pFound) - return (char8_t*)pFound; + return (char*)pFound; - return c ? NULL : (char8_t*)(pString - 1); + return c ? NULL : (char*)(pString - 1); } EASTDC_API char16_t* Strrchr(const char16_t* pString, char16_t c) @@ -2147,16 +2147,16 @@ EASTDC_API char32_t* Strrchr(const char32_t* pString, char32_t c) } -EASTDC_API size_t Strspn(const char8_t* pString, const char8_t* pSubString) +EASTDC_API size_t Strspn(const char* pString, const char* pSubString) { // This implementation does a double loop. As such, it can get slow for // very long strings. An alternative implementation is to use a hash // table or to create a bytemap of the chars in pString2. - const char8_t* pStringCurrent = pString; + const char* pStringCurrent = pString; while(*pStringCurrent) { - for(const char8_t* pSubStringCurrent = pSubString; *pSubStringCurrent != *pStringCurrent; ++pSubStringCurrent) + for(const char* pSubStringCurrent = pSubString; *pSubStringCurrent != *pStringCurrent; ++pSubStringCurrent) { if(*pSubStringCurrent == 0) return (size_t)(pStringCurrent - pString); @@ -2214,26 +2214,26 @@ EASTDC_API size_t Strspn(const char32_t* pString, const char32_t* pSubString) -EASTDC_API char8_t* Strstr(const char8_t* pString, const char8_t* pSubString) +EASTDC_API char* Strstr(const char* pString, const char* pSubString) { - char8_t* s1 = (char8_t*)pString - 1; - char8_t* p1 = (char8_t*)pSubString - 1; - char8_t c0, c1, c2; + char* s1 = (char*)pString - 1; + char* p1 = (char*)pSubString - 1; + char c0, c1, c2; if((c0 = *++p1) == 0) // An empty pSubString results in success, return pString. - return (char8_t*)pString; + return (char*)pString; while((c1 = *++s1) != 0) { if(c1 == c0) { - const char8_t* s2 = (s1 - 1); - const char8_t* p2 = (p1 - 1); + const char* s2 = (s1 - 1); + const char* p2 = (p1 - 1); while((c1 = *++s2) == (c2 = *++p2) && c1){} // Do nothing if(!c2) - return (char8_t*)s1; + return (char*)s1; } } return NULL; @@ -2291,23 +2291,23 @@ EASTDC_API char32_t* Strstr(const char32_t* pString, const char32_t* pSubString) -EASTDC_API char8_t* Stristr(const char8_t* s1, const char8_t* s2) +EASTDC_API char* Stristr(const char* s1, const char* s2) { - const char8_t* cp = s1; + const char* cp = s1; if(!*s2) - return (char8_t*)s1; + return (char*)s1; while(*cp) { - const char8_t* s = cp; - const char8_t* t = s2; + const char* s = cp; + const char* t = s2; while(*s && *t && (Tolower(*s) == Tolower(*t))) ++s, ++t; if(*t == 0) - return (char8_t*)cp; + return (char*)cp; ++cp; } @@ -2363,24 +2363,24 @@ EASTDC_API char32_t* Stristr(const char32_t* s1, const char32_t* s2) -EASTDC_API char8_t* Strrstr(const char8_t* s1, const char8_t* s2) +EASTDC_API char* Strrstr(const char* s1, const char* s2) { if(!*s2) - return (char8_t*)s1; + return (char*)s1; - const char8_t* ps1 = s1 + Strlen(s1); + const char* ps1 = s1 + Strlen(s1); while(ps1 != s1) { - const char8_t* psc1 = --ps1; - const char8_t* sc2 = s2; + const char* psc1 = --ps1; + const char* sc2 = s2; for(;;) { if(*psc1++ != *sc2++) break; else if(!*sc2) - return (char8_t*)ps1; + return (char*)ps1; } } @@ -2438,24 +2438,24 @@ EASTDC_API char32_t* Strrstr(const char32_t* s1, const char32_t* s2) -EASTDC_API char8_t* Strirstr(const char8_t* s1, const char8_t* s2) +EASTDC_API char* Strirstr(const char* s1, const char* s2) { if(!*s2) - return (char8_t*)s1; + return (char*)s1; - const char8_t* ps1 = s1 + Strlen(s1); + const char* ps1 = s1 + Strlen(s1); while(ps1 != s1) { - const char8_t* psc1 = --ps1; - const char8_t* sc2 = s2; + const char* psc1 = --ps1; + const char* sc2 = s2; for(;;) { if(Tolower(*psc1++) != Tolower(*sc2++)) break; else if(!*sc2) - return (char8_t*)ps1; + return (char*)ps1; } } @@ -2512,7 +2512,7 @@ EASTDC_API char32_t* Strirstr(const char32_t* s1, const char32_t* s2) -EASTDC_API bool Strstart(const char8_t* pString, const char8_t* pPrefix) +EASTDC_API bool Strstart(const char* pString, const char* pPrefix) { while(*pPrefix) { @@ -2549,7 +2549,7 @@ EASTDC_API bool Strstart(const char32_t* pString, const char32_t* pPrefix) -EASTDC_API bool Stristart(const char8_t* pString, const char8_t* pPrefix) +EASTDC_API bool Stristart(const char* pString, const char* pPrefix) { while(*pPrefix) { @@ -2587,7 +2587,7 @@ EASTDC_API bool Stristart(const char32_t* pString, const char32_t* pPrefix) -EASTDC_API bool Strend(const char8_t* pString, const char8_t* pSuffix, size_t stringLength, size_t suffixLength) +EASTDC_API bool Strend(const char* pString, const char* pSuffix, size_t stringLength, size_t suffixLength) { if(stringLength == kSizeTypeUnset) stringLength = Strlen(pString); @@ -2596,7 +2596,7 @@ EASTDC_API bool Strend(const char8_t* pString, const char8_t* pSuffix, size_t st suffixLength = Strlen(pSuffix); if(stringLength >= suffixLength) - return Memcmp(pString + stringLength - suffixLength, pSuffix, suffixLength * sizeof(char8_t)) == 0; + return Memcmp(pString + stringLength - suffixLength, pSuffix, suffixLength * sizeof(char)) == 0; return false; } @@ -2632,7 +2632,7 @@ EASTDC_API bool Strend(const char32_t* pString, const char32_t* pSuffix, size_t } -EASTDC_API bool Striend(const char8_t* pString, const char8_t* pSuffix, size_t stringLength, size_t suffixLength) +EASTDC_API bool Striend(const char* pString, const char* pSuffix, size_t stringLength, size_t suffixLength) { if(stringLength == kSizeTypeUnset) stringLength = Strlen(pString); @@ -2680,10 +2680,10 @@ EASTDC_API bool Striend(const char32_t* pString, const char32_t* pSuffix, size_t /////////////////////////////////////////////////////////////////// // This function was implemented by Avery Lee. // -EASTDC_API char8_t* Strtok(char8_t* pString, const char8_t* pDelimiters, char8_t** pContext) +EASTDC_API char* Strtok(char* pString, const char* pDelimiters, char** pContext) { // find point on string to resume - char8_t* s = pString; + char* s = pString; if(!s) { @@ -2693,11 +2693,11 @@ EASTDC_API char8_t* Strtok(char8_t* pString, const char8_t* pDelimiters, char8_t } // Compute bit hash based on lower 5 bits of delimiter characters - const char8_t* d = pDelimiters; + const char* d = pDelimiters; int32_t hash = 0; uint32_t delimiterCount = 0; - while(const char8_t c = *d++) + while(const char c = *d++) { hash |= (int32_t)(0x80000000 >> (c & 31)); ++delimiterCount; @@ -2706,7 +2706,7 @@ EASTDC_API char8_t* Strtok(char8_t* pString, const char8_t* pDelimiters, char8_t // Skip delimiters for(;;) { - const char8_t c = *s; + const char c = *s; // If we hit the end of the string, it ends solely with delimiters // and there are no more tokens to get. @@ -2735,10 +2735,10 @@ EASTDC_API char8_t* Strtok(char8_t* pString, const char8_t* pDelimiters, char8_t } // Mark beginning of token - char8_t* const pToken = s; + char* const pToken = s; // Search for end of token - while(const char8_t c = *s) + while(const char c = *s) { // Fast rejection against hash set if(int32_t(int64_t(hash) << (c & 31)) < 0) @@ -2937,7 +2937,7 @@ EASTDC_API char32_t* Strtok(char32_t* pString, const char32_t* pDelimiters, char -EASTDC_API const char8_t* Strtok2(const char8_t* pString, const char8_t* pDelimiters, +EASTDC_API const char* Strtok2(const char* pString, const char* pDelimiters, size_t* pResultLength, bool bFirst) { // Skip any non-delimiters @@ -2951,7 +2951,7 @@ EASTDC_API const char8_t* Strtok2(const char8_t* pString, const char8_t* pDelimi while(*pString && Strchr(pDelimiters, *pString)) ++pString; - const char8_t* const pBegin = pString; + const char* const pBegin = pString; // Calculate the length of the string while(*pString && !Strchr(pDelimiters, *pString)) @@ -3027,12 +3027,12 @@ EASTDC_API const char32_t* Strtok2(const char32_t* pString, const char32_t* pDel -EASTDC_API char8_t* Strset(char8_t* pString, int c) +EASTDC_API char* Strset(char* pString, int c) { - char8_t* pStringTemp = pString; + char* pStringTemp = pString; while(*pStringTemp) - *pStringTemp++ = (char8_t)c; + *pStringTemp++ = (char)c; return pString; } @@ -3059,12 +3059,12 @@ EASTDC_API char32_t* Strset(char32_t* pString, char32_t c) -EASTDC_API char8_t* Strnset(char8_t* pString, int c, size_t n) +EASTDC_API char* Strnset(char* pString, int c, size_t n) { - char8_t* pSaved = pString; + char* pSaved = pString; for(size_t i = 0; *pString && (i < n); ++i) - *pString++ = (char8_t)c; + *pString++ = (char)c; return pSaved; } @@ -3091,11 +3091,11 @@ EASTDC_API char32_t* Strnset(char32_t* pString, char32_t c, size_t n) -EASTDC_API char8_t* Strrev(char8_t* pString) +EASTDC_API char* Strrev(char* pString) { - for(char8_t* p1 = pString, *p2 = (pString + Strlen(pString)) - 1; p1 < p2; ++p1, --p2) + for(char* p1 = pString, *p2 = (pString + Strlen(pString)) - 1; p1 < p2; ++p1, --p2) { - char8_t c = *p2; + char c = *p2; *p2 = *p1; *p1 = c; } @@ -3128,7 +3128,7 @@ EASTDC_API char32_t* Strrev(char32_t* pString) } -EASTDC_API char8_t* Strstrip(char8_t* pString) +EASTDC_API char* Strstrip(char* pString) { // Walk forward from the beginning and find the first non-whitespace. while(EA::StdC::Isspace(*pString)) // Isspace returns false for *pString == '\0'. @@ -3138,7 +3138,7 @@ EASTDC_API char8_t* Strstrip(char8_t* pString) { // Walk backward from the end and find the last whitespace. size_t length = EA::StdC::Strlen(pString); - char8_t* pEnd = (pString + length) - 1; + char* pEnd = (pString + length) - 1; while((pEnd > pString) && EA::StdC::Isspace(*pEnd)) pEnd--; @@ -3217,17 +3217,17 @@ EASTDC_API char32_t* Strstrip(char32_t* pString) // Some platforms have an optimized vector implementation of strcmp which is fast and which provides // identical return value behavior to our Strcmp (which is to return the byte difference and not just // -1, 0, +1). And so until we have our own vectored version we use the built-in version. - EASTDC_API int Strcmp(const char8_t* pString1, const char8_t* pString2) + EASTDC_API int Strcmp(const char* pString1, const char* pString2) { return strcmp(pString1, pString2); } #else // To do: Implement an x86/x64 vectorized version of Strcmp, which can work on 16 byte chunks and thus be faster than below. - EASTDC_API int Strcmp(const char8_t* pString1, const char8_t* pString2) + EASTDC_API int Strcmp(const char* pString1, const char* pString2) { - if(IsAligned(pString1) && // If pString1 and pString2 are word-aligned... compare in word-sized chunks. - IsAligned(pString2)) + if(IsAligned(pString1) && // If pString1 and pString2 are word-aligned... compare in word-sized chunks. + IsAligned(pString2)) { const word_type* pWord1 = (word_type*)pString1; const word_type* pWord2 = (word_type*)pString2; @@ -3240,8 +3240,8 @@ EASTDC_API char32_t* Strstrip(char32_t* pString) } // At this point, the strings differ somewhere in the bytes pointed to by pWord1/pWord2. - pString1 = reinterpret_cast(pWord1); // Fall through and do byte comparisons for the rest of the string. - pString2 = reinterpret_cast(pWord2); + pString1 = reinterpret_cast(pWord1); // Fall through and do byte comparisons for the rest of the string. + pString2 = reinterpret_cast(pWord2); } while(*pString1 && (*pString1 == *pString2)) @@ -3254,9 +3254,9 @@ EASTDC_API char32_t* Strstrip(char32_t* pString) } #endif #else - EASTDC_API int Strcmp(const char8_t* pString1, const char8_t* pString2) + EASTDC_API int Strcmp(const char* pString1, const char* pString2) { - char8_t c1, c2; + char c1, c2; while((c1 = *pString1++) == (c2 = *pString2++)) { @@ -3337,7 +3337,7 @@ EASTDC_API int Strcmp(const char32_t* pString1, const char32_t* pString2) // Some platforms have an optimized vector implementation of strncmp which is fast and which provides // identical return value behavior to our Strncmp (which is to return the byte difference and not just // -1, 0, +1). And so until we have our own vectored version we use the built-in version. - EASTDC_API int Strncmp(const char8_t* pString1, const char8_t* pString2, size_t n) + EASTDC_API int Strncmp(const char* pString1, const char* pString2, size_t n) { return strncmp(pString1, pString2, n); } @@ -3345,9 +3345,9 @@ EASTDC_API int Strcmp(const char32_t* pString1, const char32_t* pString2) // To do: Implement a general portable version of a more optimized Strncmp. #else - EASTDC_API int Strncmp(const char8_t* pString1, const char8_t* pString2, size_t n) + EASTDC_API int Strncmp(const char* pString1, const char* pString2, size_t n) { - char8_t c1, c2; + char c1, c2; ++n; while(--n) @@ -3406,7 +3406,7 @@ EASTDC_API int Strncmp(const char32_t* pString1, const char32_t* pString2, size_ // Some platforms have an optimized vector implementation of stricmp/strcasecmp which is fast and which provides // identical return value behavior to our Stricmp (which is to return the byte difference and not just // -1, 0, +1). And so until we have our own vectored version we use the built-in version. - EASTDC_API int Stricmp(const char8_t* pString1, const char8_t* pString2) + EASTDC_API int Stricmp(const char* pString1, const char* pString2) { return strcasecmp(pString1, pString2); } @@ -3414,9 +3414,9 @@ EASTDC_API int Strncmp(const char32_t* pString1, const char32_t* pString2, size_ // To do: Implement a general portable version of a more optimized Stricmp. #else - EASTDC_API int Stricmp(const char8_t* pString1, const char8_t* pString2) + EASTDC_API int Stricmp(const char* pString1, const char* pString2) { - char8_t c1, c2; + char c1, c2; while((c1 = Tolower(*pString1++)) == (c2 = Tolower(*pString2++))) { @@ -3460,9 +3460,9 @@ EASTDC_API int Stricmp(const char32_t* pString1, const char32_t* pString2) -EASTDC_API int Strnicmp(const char8_t* pString1, const char8_t* pString2, size_t n) +EASTDC_API int Strnicmp(const char* pString1, const char* pString2, size_t n) { - char8_t c1, c2; + char c1, c2; ++n; while(--n) @@ -3518,12 +3518,12 @@ EASTDC_API int Strnicmp(const char32_t* pString1, const char32_t* pString2, size // *** this function is deprecated. *** -EASTDC_API int StrcmpAlnum(const char8_t* pString1, const char8_t* pString2) +EASTDC_API int StrcmpAlnum(const char* pString1, const char* pString2) { - char8_t c1, c2; - const char8_t* pStart1 = pString1; - const char8_t* pStart2 = pString2; - const char8_t* pDigitStart1 = pString1; + char c1, c2; + const char* pStart1 = pString1; + const char* pStart2 = pString2; + const char* pDigitStart1 = pString1; while(((c1 = *pString1++) == (c2 = *pString2++)) && c1) { @@ -3572,12 +3572,12 @@ EASTDC_API int StrcmpAlnum(const char16_t* pString1, const char16_t* pString2) // *** this function is deprecated. *** -EASTDC_API int StricmpAlnum(const char8_t* pString1, const char8_t* pString2) +EASTDC_API int StricmpAlnum(const char* pString1, const char* pString2) { - char8_t c1, c2; - const char8_t* pStart1 = pString1; - const char8_t* pStart2 = pString2; - const char8_t* pDigitStart1 = pString1; + char c1, c2; + const char* pStart1 = pString1; + const char* pStart2 = pString2; + const char* pDigitStart1 = pString1; while(((c1 = Tolower(*pString1++)) == (c2 = Tolower(*pString2++))) && c1) { @@ -3626,9 +3626,9 @@ EASTDC_API int StricmpAlnum(const char16_t* pString1, const char16_t* pString2) -EASTDC_API int StrcmpNumeric(const char8_t* pString1, const char8_t* pString2, +EASTDC_API int StrcmpNumeric(const char* pString1, const char* pString2, size_t length1, size_t length2, - char8_t decimal, char8_t thousandsSeparator) + char decimal, char thousandsSeparator) { // To do: Implement this function. Ask Paul Pedriana to implement this if you need it. EA_UNUSED(pString1); @@ -3674,9 +3674,9 @@ EASTDC_API int StrcmpNumeric(const char32_t* pString1, const char32_t* pString2, -EASTDC_API int StricmpNumeric(const char8_t* pString1, const char8_t* pString2, +EASTDC_API int StricmpNumeric(const char* pString1, const char* pString2, size_t length1, size_t length2, - char8_t decimal, char8_t thousandsSeparator) + char decimal, char thousandsSeparator) { // To do: Implement this function. Ask Paul Pedriana to implement this if you need it. EA_UNUSED(pString1); @@ -3723,7 +3723,7 @@ EASTDC_API int StricmpNumeric(const char32_t* pString1, const char32_t* pString2 -EASTDC_API int Strcoll(const char8_t* pString1, const char8_t* pString2) +EASTDC_API int Strcoll(const char* pString1, const char* pString2) { // The user needs to use a localization package to get proper localized collation. return Strcmp(pString1, pString2); @@ -3744,7 +3744,7 @@ EASTDC_API int Strcoll(const char32_t* pString1, const char32_t* pString2) -EASTDC_API int Strncoll(const char8_t* pString1, const char8_t* pString2, size_t n) +EASTDC_API int Strncoll(const char* pString1, const char* pString2, size_t n) { // The user needs to use a localization package to get proper localized collation. return Strncmp(pString1, pString2, n); @@ -3765,7 +3765,7 @@ EASTDC_API int Strncoll(const char32_t* pString1, const char32_t* pString2, size -EASTDC_API int Stricoll(const char8_t* pString1, const char8_t* pString2) +EASTDC_API int Stricoll(const char* pString1, const char* pString2) { // The user needs to use a localization package to get proper localized collation. return Stricmp(pString1, pString2); @@ -3786,7 +3786,7 @@ EASTDC_API int Stricoll(const char32_t* pString1, const char32_t* pString2) -EASTDC_API int Strnicoll(const char8_t* pString1, const char8_t* pString2, size_t n) +EASTDC_API int Strnicoll(const char* pString1, const char* pString2, size_t n) { // The user needs to use a localization package to get proper localized collation. return Strnicmp(pString1, pString2, n); @@ -3812,12 +3812,12 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz // EcvtBuf / FcvtBuf // #if EASTDC_NATIVE_FCVT - EASTDC_API char8_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char8_t* buffer) + EASTDC_API char* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char* buffer) { #ifdef __GNUC__ - const char8_t* const pResult = ecvt(dValue, nDigitCount, decimalPos, sign); + const char* const pResult = ecvt(dValue, nDigitCount, decimalPos, sign); #else - const char8_t* const pResult = _ecvt(dValue, nDigitCount, decimalPos, sign); + const char* const pResult = _ecvt(dValue, nDigitCount, decimalPos, sign); #endif strcpy(buffer, pResult); @@ -3837,12 +3837,12 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz return buffer; } - EASTDC_API char8_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char8_t* buffer) + EASTDC_API char* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char* buffer) { #ifdef __GNUC__ - const char8_t* const pResult = fcvt(dValue, nDigitCountAfterDecimal, decimalPos, sign); + const char* const pResult = fcvt(dValue, nDigitCountAfterDecimal, decimalPos, sign); #else - char8_t pResult[_CVTBUFSIZE+1]; + char pResult[_CVTBUFSIZE+1]; _fcvt_s(pResult, sizeof(pResult), dValue, nDigitCountAfterDecimal, decimalPos, sign); #endif @@ -3935,7 +3935,7 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz }; - EASTDC_API char8_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char8_t* buffer) + EASTDC_API char* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char* buffer) { int nDigitCountAfterDecimal; double fract; @@ -3943,10 +3943,10 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz double tmp; int neg = 0; int expcnt = 0; - char8_t* buf = buffer; - char8_t* t = buf; - char8_t* p = buf + kEcvtBufMaxSize - 1; - char8_t* pbuf = p; + char* buf = buffer; + char* t = buf; + char* p = buf + kEcvtBufMaxSize - 1; + char* pbuf = p; // We follow the same preconditions as Microsoft does with its _ecvt function. EA_ASSERT((nDigitCount >= 0) && (decimalPos != NULL) && (sign != NULL) && (buffer != NULL)); @@ -4018,7 +4018,7 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz for(; integer; ++expcnt) { tmp = modf(integer / 10.0f, &integer); - *p-- = (char8_t)((int)((tmp + 0.01f) * 10.0f) + '0'); + *p-- = (char)((int)((tmp + 0.01f) * 10.0f) + '0'); EA_ASSERT(p >= buffer); } } @@ -4077,14 +4077,14 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz else { leading = false; - *t++ = (char8_t)((int)tmp + '0'); + *t++ = (char)((int)tmp + '0'); nDigitCountAfterDecimal -= 1; } } if(fract) { - char8_t* scan = (t - 1); + char* scan = (t - 1); // round off the number modf(fract * 10.0f, &tmp); @@ -4140,16 +4140,16 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz } - EASTDC_API char8_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char8_t* buffer) + EASTDC_API char* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char* buffer) { double fract; double integer; double tmp; int neg = 0; int expcnt = 0; - char8_t* buf = buffer; - char8_t* t = buf; - char8_t* p = buf + kFcvtBufMaxSize - 1; + char* buf = buffer; + char* t = buf; + char* p = buf + kFcvtBufMaxSize - 1; // We follow the same preconditions as Microsoft does with its _fcvt function. EA_ASSERT((nDigitCountAfterDecimal >= 0) && (decimalPos != NULL) && (sign != NULL) && (buffer != NULL)); @@ -4217,7 +4217,7 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz for(; integer; ++expcnt) { tmp = modf(integer / 10.0f, &integer); - *p-- = (char8_t)((int)((tmp + 0.01f) * 10.0f) + '0'); + *p-- = (char)((int)((tmp + 0.01f) * 10.0f) + '0'); EA_ASSERT(p >= buffer); } } @@ -4239,14 +4239,14 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz while(count && fract) { fract = modf(fract * 10.0f, &tmp); - *t++ = (char8_t)((int)tmp + '0'); + *t++ = (char)((int)tmp + '0'); nDigitCountAfterDecimal--; count--; } if(fract) { - char8_t* scan = (t - 1); + char* scan = (t - 1); // round off the number modf(fract * 10.0f, &tmp); @@ -4311,12 +4311,12 @@ EASTDC_API int Strnicoll(const char32_t* pString1, const char32_t* pString2, siz EASTDC_API char16_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char16_t* buffer) { // We implement this by calling the 8 bit version and copying its data. - char8_t pBufferCvt8[kEcvtBufMaxSize]; + char pBufferCvt8[kEcvtBufMaxSize]; char16_t* pCurrent16 = buffer; EcvtBuf(dValue, nDigitCount, decimalPos, sign, pBufferCvt8); - for(char8_t* pCurrent8 = pBufferCvt8; *pCurrent8; ) // Do a 8 bit to 16 bit strcpy. + for(char* pCurrent8 = pBufferCvt8; *pCurrent8; ) // Do a 8 bit to 16 bit strcpy. *pCurrent16++ = (char16_t)(unsigned char)*pCurrent8++; *pCurrent16 = 0; @@ -4327,12 +4327,12 @@ EASTDC_API char16_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, in EASTDC_API char32_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char32_t* buffer) { // We implement this by calling the 8 bit version and copying its data. - char8_t pBufferCvt8[kEcvtBufMaxSize]; + char pBufferCvt8[kEcvtBufMaxSize]; char32_t* pCurrent32 = buffer; EcvtBuf(dValue, nDigitCount, decimalPos, sign, pBufferCvt8); - for(char8_t* pCurrent8 = pBufferCvt8; *pCurrent8; ) // Do a 8 bit to 32 bit strcpy. + for(char* pCurrent8 = pBufferCvt8; *pCurrent8; ) // Do a 8 bit to 32 bit strcpy. *pCurrent32++ = (char32_t)(unsigned char)*pCurrent8++; *pCurrent32 = 0; @@ -4346,12 +4346,12 @@ EASTDC_API char32_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, in EASTDC_API char16_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char16_t* buffer) { // We implement this by calling the 8 bit version and copying its data. - char8_t pBufferCvt8[kEcvtBufMaxSize]; + char pBufferCvt8[kEcvtBufMaxSize]; char16_t* pCurrent16 = buffer; FcvtBuf(dValue, nDigitCountAfterDecimal, decimalPos, sign, pBufferCvt8); - for(char8_t* pCurrent8 = pBufferCvt8; *pCurrent8; ) // Do a 8 bit to 16 bit strcpy. + for(char* pCurrent8 = pBufferCvt8; *pCurrent8; ) // Do a 8 bit to 16 bit strcpy. *pCurrent16++ = (char16_t)(unsigned char)*pCurrent8++; *pCurrent16 = 0; @@ -4362,12 +4362,12 @@ EASTDC_API char16_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* de EASTDC_API char32_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char32_t* buffer) { // We implement this by calling the 8 bit version and copying its data. - char8_t pBufferCvt8[kEcvtBufMaxSize]; + char pBufferCvt8[kEcvtBufMaxSize]; char32_t* pCurrent32 = buffer; FcvtBuf(dValue, nDigitCountAfterDecimal, decimalPos, sign, pBufferCvt8); - for(char8_t* pCurrent8 = pBufferCvt8; *pCurrent8; ) // Do a 8 bit to 32 bit strcpy. + for(char* pCurrent8 = pBufferCvt8; *pCurrent8; ) // Do a 8 bit to 32 bit strcpy. *pCurrent32++ = (char32_t)(unsigned char)*pCurrent8++; *pCurrent32 = 0; @@ -4416,9 +4416,9 @@ static uint32_t digits10(uint64_t v) return 12 + digits10(v / UINT64_C(1000000000000)); } -char8_t* X64toaCommon10(uint64_t nValue, char8_t* pBuffer) +char* X64toaCommon10(uint64_t nValue, char* pBuffer) { - static const char8_t digits[201] = + static const char digits[201] = "0001020304050607080910111213141516171819202122232425262728293031323334353637383940414243444546474849" "5051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899"; @@ -4437,7 +4437,7 @@ char8_t* X64toaCommon10(uint64_t nValue, char8_t* pBuffer) } if (nValue < 10) - pBuffer[next] = (char8_t)('0' + (uint32_t)nValue); + pBuffer[next] = (char)('0' + (uint32_t)nValue); else { const uint32_t i = (uint32_t)nValue * 2; @@ -4449,9 +4449,9 @@ char8_t* X64toaCommon10(uint64_t nValue, char8_t* pBuffer) } -static char8_t* X64toaCommon(uint64_t nValue, char8_t* pBuffer, int nBase, bool bNegative) +static char* X64toaCommon(uint64_t nValue, char* pBuffer, int nBase, bool bNegative) { - char8_t* pCurrent = pBuffer; + char* pCurrent = pBuffer; if(bNegative) *pCurrent++ = '-'; @@ -4460,23 +4460,23 @@ static char8_t* X64toaCommon(uint64_t nValue, char8_t* pBuffer, int nBase, bool X64toaCommon10(nValue, pCurrent); else { - char8_t* pFirstDigit = pCurrent; + char* pFirstDigit = pCurrent; do{ const unsigned nDigit = (unsigned)(nValue % nBase); nValue /= nBase; if(nDigit > 9) - *pCurrent++ = (char8_t)(nDigit - 10 + 'a'); + *pCurrent++ = (char)(nDigit - 10 + 'a'); else - *pCurrent++ = (char8_t)(nDigit + '0'); + *pCurrent++ = (char)(nDigit + '0'); } while(nValue > 0); // Need to reverse the string. *pCurrent-- = 0; do{ - const char8_t cTemp = *pCurrent; + const char cTemp = *pCurrent; *pCurrent-- = *pFirstDigit; *pFirstDigit++ = cTemp; }while(pFirstDigit < pCurrent); @@ -4550,7 +4550,7 @@ static char32_t* X64toaCommon(uint64_t nValue, char32_t* pBuffer, int nBase, boo -EASTDC_API char8_t* I32toa(int32_t nValue, char8_t* pBuffer, int nBase) +EASTDC_API char* I32toa(int32_t nValue, char* pBuffer, int nBase) { const bool bNegative = (nValue < 0) && (nBase == 10); @@ -4597,7 +4597,7 @@ EASTDC_API char32_t* I32toa(int32_t nValue, char32_t* pBuffer, int nBase) -EASTDC_API char8_t* U32toa(uint32_t nValue, char8_t* pBuffer, int nBase) +EASTDC_API char* U32toa(uint32_t nValue, char* pBuffer, int nBase) { return X64toaCommon((uint64_t)nValue, pBuffer, nBase, 0); } @@ -4615,7 +4615,7 @@ EASTDC_API char32_t* U32toa(uint32_t nValue, char32_t* pBuffer, int nBase) -EASTDC_API char8_t* I64toa(int64_t nValue, char8_t* pBuffer, int nBase) +EASTDC_API char* I64toa(int64_t nValue, char* pBuffer, int nBase) { const bool bNegative = (nValue < 0) && (nBase == 10); @@ -4648,7 +4648,7 @@ EASTDC_API char32_t* I64toa(int64_t nValue, char32_t* pBuffer, int nBase) -EASTDC_API char8_t* U64toa(uint64_t nValue, char8_t* pBuffer, int nBase) +EASTDC_API char* U64toa(uint64_t nValue, char* pBuffer, int nBase) { return X64toaCommon(nValue, pBuffer, nBase, 0); } @@ -4667,16 +4667,16 @@ EASTDC_API char32_t* U64toa(uint64_t nValue, char32_t* pBuffer, int nBase) -EASTDC_API double StrtodEnglish(const char8_t* pValue, char8_t** ppEnd) +EASTDC_API double StrtodEnglish(const char* pValue, char** ppEnd) { // This implementation is an exact copy of StrtodEnglish but - // with char8_t in place of char16_t. For the time being, if + // with char in place of char16_t. For the time being, if // you do maintenance on either of these functions, you need to // copy the result to the other version. int c; double dTotal(0.0); - char8_t chSign('+'); - const char8_t* pEnd = pValue; + char chSign('+'); + const char* pEnd = pValue; while(Isspace(*pValue)) ++pValue; //Remove leading spaces. @@ -4684,7 +4684,7 @@ EASTDC_API double StrtodEnglish(const char8_t* pValue, char8_t** ppEnd) pEnd = pValue; c = *pValue++; if(c == '-' || c == '+'){ - chSign = (char8_t)c; + chSign = (char)c; pEnd = pValue; c = *pValue++; } @@ -4711,13 +4711,13 @@ EASTDC_API double StrtodEnglish(const char8_t* pValue, char8_t** ppEnd) if(c == 'e' || c == 'E'){ int nExponentValue(0); double dExponentTotal; - char8_t chExponentSign('+'); + char chExponentSign('+'); pEnd = pValue; c = *pValue++; //Move past the exponent. if(c == '-' || c == '+'){ - chExponentSign = (char8_t)c; + chExponentSign = (char)c; pEnd = pValue; c = *pValue++; //Move past the '+' or '-' sign. } @@ -4736,7 +4736,7 @@ EASTDC_API double StrtodEnglish(const char8_t* pValue, char8_t** ppEnd) } if(ppEnd) - *ppEnd = (char8_t*)pEnd; + *ppEnd = (char*)pEnd; if(chSign == '-') return -dTotal; @@ -4898,12 +4898,12 @@ EASTDC_API double StrtodEnglish(const char32_t* pValue, char32_t** ppEnd) -static uint64_t StrtoU64Common(const char8_t* pValue, char8_t** ppEnd, int nBase, bool bUnsigned) +static uint64_t StrtoU64Common(const char* pValue, char** ppEnd, int nBase, bool bUnsigned) { uint64_t nValue(0); // Current value - const char8_t* p = pValue; // Current position - char8_t c; // Temp value - char8_t chSign('+'); // One of either '+' or '-' + const char* p = pValue; // Current position + char c; // Temp value + char chSign('+'); // One of either '+' or '-' bool bDigitWasRead(false); // True if any digits were read. bool bOverflowOccurred(false); // True if integer overflow occurred. @@ -4921,7 +4921,7 @@ static uint64_t StrtoU64Common(const char8_t* pValue, char8_t** ppEnd, int nBase // Do checks on nBase. if((nBase < 0) || (nBase == 1) || (nBase > 36)){ if(ppEnd) - *ppEnd = (char8_t*)pValue; + *ppEnd = (char*)pValue; return 0; } else if(nBase == 0){ @@ -5016,7 +5016,7 @@ static uint64_t StrtoU64Common(const char8_t* pValue, char8_t** ppEnd, int nBase } if(ppEnd) - *ppEnd = (char8_t*)p; + *ppEnd = (char*)p; if(chSign == '-') nValue = -nValue; @@ -5282,7 +5282,7 @@ static uint64_t StrtoU64Common(const char32_t* pValue, char32_t** ppEnd, int nBa -EASTDC_API int32_t StrtoI32(const char8_t* pValue, char8_t** ppEnd, int nBase) +EASTDC_API int32_t StrtoI32(const char* pValue, char** ppEnd, int nBase) { int64_t val = (int64_t) StrtoU64Common(pValue, ppEnd, nBase, false); @@ -5354,7 +5354,7 @@ EASTDC_API int32_t StrtoI32(const char32_t* pValue, char32_t** ppEnd, int nBase) -EASTDC_API uint32_t StrtoU32(const char8_t* pValue, char8_t** ppEnd, int nBase) +EASTDC_API uint32_t StrtoU32(const char* pValue, char** ppEnd, int nBase) { uint64_t val = StrtoU64Common(pValue, ppEnd, nBase, true); @@ -5402,7 +5402,7 @@ EASTDC_API uint32_t StrtoU32(const char32_t* pValue, char32_t** ppEnd, int nBase -EASTDC_API int64_t StrtoI64(const char8_t* pString, char8_t** ppStringEnd, int nBase) +EASTDC_API int64_t StrtoI64(const char* pString, char** ppStringEnd, int nBase) { return (int64_t)StrtoU64Common(pString, ppStringEnd, nBase, false); } @@ -5419,7 +5419,7 @@ EASTDC_API int64_t StrtoI64(const char32_t* pString, char32_t** ppStringEnd, int -EASTDC_API uint64_t StrtoU64(const char8_t* pString, char8_t** ppStringEnd, int nBase) +EASTDC_API uint64_t StrtoU64(const char* pString, char** ppStringEnd, int nBase) { return StrtoU64Common(pString, ppStringEnd, nBase, true); } @@ -5436,7 +5436,7 @@ EASTDC_API uint64_t StrtoU64(const char32_t* pString, char32_t** ppStringEnd, in -EASTDC_API char8_t* FtoaEnglish(double dValue, char8_t* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled) +EASTDC_API char* FtoaEnglish(double dValue, char* pResult, int nResultCapacity, int nPrecision, bool bExponentEnabled) { // Note that this function is a duplicate of FtoaEnglish16 but // with char instead of char16_t. Modifications to either of @@ -5474,10 +5474,10 @@ EASTDC_API char8_t* FtoaEnglish(double dValue, char8_t* pResult, int nResultCapa const double dExpPow = ::pow(10.0, (double)-nExponent); if(FtoaEnglish(dValue * dExpPow, pResult, nResultCapacity - nDigits - 2, nPrecision, false)){ - char8_t* p = pResult + Strlen(pResult); + char* p = pResult + Strlen(pResult); - *p++ = (char8_t)'e'; - *p++ = ((nExponent < 0) ? (char8_t)'-' : (char8_t)'+'); + *p++ = (char)'e'; + *p++ = ((nExponent < 0) ? (char)'-' : (char)'+'); I32toa(abs(nExponent), p, 10); return pResult; } @@ -5493,14 +5493,14 @@ EASTDC_API char8_t* FtoaEnglish(double dValue, char8_t* pResult, int nResultCapa // is locale-savvy. Actually, not all compilers implement fcvt. #if EASTDC_NATIVE_FCVT #ifdef __GNUC__ // nPrecision refers to the number of digits after the decimal point. - const char8_t* const pResultTemp = fcvt(dValue, nPrecision, &nDecimalPosition, &nSign); + const char* const pResultTemp = fcvt(dValue, nPrecision, &nDecimalPosition, &nSign); #else - char8_t pResultTemp[_CVTBUFSIZE+1]; + char pResultTemp[_CVTBUFSIZE+1]; _fcvt_s(pResultTemp, sizeof(pResultTemp), dValue, nPrecision, &nDecimalPosition, &nSign); #endif #else - char8_t bufferTemp[kFcvtBufMaxSize]; - const char8_t* const pResultTemp = FcvtBuf(dValue, nPrecision, &nDecimalPosition, &nSign, bufferTemp); + char bufferTemp[kFcvtBufMaxSize]; + const char* const pResultTemp = FcvtBuf(dValue, nPrecision, &nDecimalPosition, &nSign, bufferTemp); #endif // If the value is negative, then add a leading '-' sign. @@ -5656,13 +5656,13 @@ EASTDC_API char16_t* FtoaEnglish(double dValue, char16_t* pResult, int nResultCa // is locale-savvy. Actually, not all compilers implement fcvt. #if EASTDC_NATIVE_FCVT #ifdef __GNUC__ - const char8_t* const pResultTemp = fcvt(dValue, nPrecision, &nDecimalPosition, &nSign); + const char* const pResultTemp = fcvt(dValue, nPrecision, &nDecimalPosition, &nSign); #else - const char8_t* const pResultTemp = _fcvt(dValue, nPrecision, &nDecimalPosition, &nSign); + const char* const pResultTemp = _fcvt(dValue, nPrecision, &nDecimalPosition, &nSign); #endif #else - char8_t bufferTemp[kFcvtBufMaxSize]; - const char8_t* const pResultTemp = FcvtBuf(dValue, nPrecision, &nDecimalPosition, &nSign, bufferTemp); + char bufferTemp[kFcvtBufMaxSize]; + const char* const pResultTemp = FcvtBuf(dValue, nPrecision, &nDecimalPosition, &nSign, bufferTemp); #endif // If the value is negative, then add a leading '-' sign. @@ -5818,13 +5818,13 @@ EASTDC_API char32_t* FtoaEnglish(double dValue, char32_t* pResult, int nResultCa // is locale-savvy. Actually, not all compilers implement fcvt. #if EASTDC_NATIVE_FCVT #ifdef __GNUC__ - const char8_t* const pResultTemp = fcvt(dValue, nPrecision, &nDecimalPosition, &nSign); + const char* const pResultTemp = fcvt(dValue, nPrecision, &nDecimalPosition, &nSign); #else - const char8_t* const pResultTemp = _fcvt(dValue, nPrecision, &nDecimalPosition, &nSign); + const char* const pResultTemp = _fcvt(dValue, nPrecision, &nDecimalPosition, &nSign); #endif #else - char8_t bufferTemp[kFcvtBufMaxSize]; - const char8_t* const pResultTemp = FcvtBuf(dValue, nPrecision, &nDecimalPosition, &nSign, bufferTemp); + char bufferTemp[kFcvtBufMaxSize]; + const char* const pResultTemp = FcvtBuf(dValue, nPrecision, &nDecimalPosition, &nSign, bufferTemp); #endif // If the value is negative, then add a leading '-' sign. @@ -5926,7 +5926,7 @@ EASTDC_API char32_t* FtoaEnglish(double dValue, char32_t* pResult, int nResultCa -EASTDC_API size_t ReduceFloatString(char8_t* pString, size_t nLength) +EASTDC_API size_t ReduceFloatString(char* pString, size_t nLength) { if(nLength == (size_t)-1) nLength = strlen(pString); @@ -6024,7 +6024,7 @@ EASTDC_API size_t ReduceFloatString(char8_t* pString, size_t nLength) if((nNewLength >= 3) && (pString[0] == '0') && (pString[1] == '.')) // If we have "0.x" { - memmove(pString, pString + 1, nNewLength * sizeof(char8_t)); + memmove(pString, pString + 1, nNewLength * sizeof(char)); nNewLength--; } } @@ -6036,8 +6036,8 @@ EASTDC_API size_t ReduceFloatString(char8_t* pString, size_t nLength) EASTDC_API size_t ReduceFloatString(char16_t* pString, size_t nLength) { // We implement this by calling the 8 bit version and copying its data. - char8_t pBuffer8[64]; - char8_t* pCurrent8; + char pBuffer8[64]; + char* pCurrent8; char16_t* pCurrent16; size_t n = 0; @@ -6045,7 +6045,7 @@ EASTDC_API size_t ReduceFloatString(char16_t* pString, size_t nLength) nLength = 63; for(pCurrent8 = pBuffer8, pCurrent16 = pString; *pCurrent16 && (n < nLength); ++n) // Do a 16 bit to 8 bit strcpy. - *pCurrent8++ = (char8_t)(unsigned char)*pCurrent16++; + *pCurrent8++ = (char)(unsigned char)*pCurrent16++; *pCurrent8 = 0; @@ -6062,8 +6062,8 @@ EASTDC_API size_t ReduceFloatString(char16_t* pString, size_t nLength) EASTDC_API size_t ReduceFloatString(char32_t* pString, size_t nLength) { // We implement this by calling the 8 bit version and copying its data. - char8_t pBuffer8[64]; - char8_t* pCurrent8; + char pBuffer8[64]; + char* pCurrent8; char32_t* pCurrent32; size_t n = 0; @@ -6071,7 +6071,7 @@ EASTDC_API size_t ReduceFloatString(char32_t* pString, size_t nLength) nLength = 63; for(pCurrent8 = pBuffer8, pCurrent32 = pString; *pCurrent32 && (n < nLength); ++n) // Do a 32 bit to 8 bit strcpy. - *pCurrent8++ = (char8_t)(unsigned char)*pCurrent32++; + *pCurrent8++ = (char)(unsigned char)*pCurrent32++; *pCurrent8 = 0; diff --git a/source/EATextUtil.cpp b/source/EATextUtil.cpp index 55b4ef5..1a57a98 100644 --- a/source/EATextUtil.cpp +++ b/source/EATextUtil.cpp @@ -53,7 +53,7 @@ extern uint8_t utf8lengthTable[256]; // See 'http://www.cl.cam.ac.uk/~mgk25/unicode.html' or search for "UTF8 FAQ" // on the Internet for more details on UTF8 and Unicode. // -EASTDC_API bool UTF8Validate(const char8_t* pText, size_t nLength) +EASTDC_API bool UTF8Validate(const char* pText, size_t nLength) { const uint8_t* pSource8 = (const uint8_t*)pText; const uint8_t* const pSource8End = pSource8 + nLength; @@ -145,7 +145,7 @@ EASTDC_API bool UTF8Validate(const char8_t* pText, size_t nLength) // The string must be a valid UTF8 string or else the behavior is undefined. // If the string is not known to be valid, then it should be first validated independently // or a validating version of this function should be used instead. -EASTDC_API char8_t* UTF8Increment(const char8_t* p, size_t n) +EASTDC_API char* UTF8Increment(const char* p, size_t n) { while(n--) { @@ -169,7 +169,7 @@ EASTDC_API char8_t* UTF8Increment(const char8_t* p, size_t n) p += 1; // Error. We return 1 instead of 0 or -1 because the user is probably iterating a string and so this is safer. } - return (char8_t*)p; + return (char*)p; } @@ -179,7 +179,7 @@ EASTDC_API char8_t* UTF8Increment(const char8_t* p, size_t n) // The string must be a valid UTF8 string or else the behavior is undefined. // If the string is not known to be valid, then it should be first validated independently // or a validating version of this function should be used instead. -EASTDC_API char8_t* UTF8Decrement(const char8_t* p, size_t n) +EASTDC_API char* UTF8Decrement(const char* p, size_t n) { while(n) { @@ -187,7 +187,7 @@ EASTDC_API char8_t* UTF8Decrement(const char8_t* p, size_t n) --n; } - return (char8_t*)p; + return (char*)p; } @@ -197,7 +197,7 @@ EASTDC_API char8_t* UTF8Decrement(const char8_t* p, size_t n) // The string must be a valid UTF8 string or else the behavior is undefined. // If the string is not known to be valid, then it should be first validated independently // or a validating version of this function should be used instead. -EASTDC_API size_t UTF8Length(const char8_t* p) +EASTDC_API size_t UTF8Length(const char* p) { size_t n = 0; @@ -280,7 +280,7 @@ EASTDC_API size_t UTF8Length(const char32_t* p) // 0xfc-0xfd are first byte of a 6-tuplet. // 0xfe-0xff are invalid values for a leading UTF8 char. // -EASTDC_API size_t UTF8CharSize(const char8_t* p) +EASTDC_API size_t UTF8CharSize(const char* p) { // To do: Change this code to instead use the utf8lengthTable fropm EAString.cpp @@ -345,10 +345,10 @@ EASTDC_API size_t UTF8CharSize(char32_t c) } -EASTDC_API char16_t UTF8ReadChar(const char8_t* p, const char8_t** ppEnd) +EASTDC_API char16_t UTF8ReadChar(const char* p, const char** ppEnd) { char16_t c = 0; - const char8_t* pCurrent; + const char* pCurrent; uint8_t cChar0((uint8_t)*p), cChar1, cChar2, cChar3; //assert((cChar0 != 0xFE) && (cChar0 != 0xFF)); // No byte can contain 0xFE or 0xFF @@ -423,29 +423,29 @@ EASTDC_API char16_t UTF8ReadChar(const char8_t* p, const char8_t** ppEnd) // This function assumes that there is enough space at p to write the char. // At most three bytes are needed to write a char16_t value and 6 bytes are // needed to write a char32_t value. -EASTDC_API char8_t* UTF8WriteChar(char8_t* p, char16_t c) +EASTDC_API char* UTF8WriteChar(char* p, char16_t c) { if(c < 0x80) { - *p++ = (char8_t)(uint8_t)c; + *p++ = (char)(uint8_t)c; } else if(c < 0x0800) { - *p++ = (char8_t)(uint8_t)((c >> 6) | 0xC0); - *p++ = (char8_t)(uint8_t)((c & 0x3F) | 0x80); + *p++ = (char)(uint8_t)((c >> 6) | 0xC0); + *p++ = (char)(uint8_t)((c & 0x3F) | 0x80); } else // if(c < 0x00010000) { - *p++ = (char8_t)(uint8_t)((c >> 12) | 0xE0); - *p++ = (char8_t)(uint8_t)(((c >> 6) & 0x3F) | 0x80); - *p++ = (char8_t)(uint8_t)((c & 0x3F) | 0x80); + *p++ = (char)(uint8_t)((c >> 12) | 0xE0); + *p++ = (char)(uint8_t)(((c >> 6) & 0x3F) | 0x80); + *p++ = (char)(uint8_t)((c & 0x3F) | 0x80); } //else //{ - // *p++ = (char8_t)(uint8_t)((c >> 18) | 0xF0); - // *p++ = (char8_t)(uint8_t)(((c >> 12) & 0x3F) | 0x80); - // *p++ = (char8_t)(uint8_t)(((c >> 6) & 0x3F) | 0x80); - // *p++ = (char8_t)(uint8_t)((c & 0x3F) | 0x80); + // *p++ = (char)(uint8_t)((c >> 18) | 0xF0); + // *p++ = (char)(uint8_t)(((c >> 12) & 0x3F) | 0x80); + // *p++ = (char)(uint8_t)(((c >> 6) & 0x3F) | 0x80); + // *p++ = (char)(uint8_t)((c & 0x3F) | 0x80); //} return p; @@ -454,29 +454,29 @@ EASTDC_API char8_t* UTF8WriteChar(char8_t* p, char16_t c) // This function assumes that there is enough space at p to write the char. // At most three bytes are needed to write a char32_t value and 6 bytes are // needed to write a char32_t value. -EASTDC_API char8_t* UTF8WriteChar(char8_t* p, char32_t c) +EASTDC_API char* UTF8WriteChar(char* p, char32_t c) { if((uint32_t)c < 0x80) { - *p++ = (char8_t)(uint8_t)c; + *p++ = (char)(uint8_t)c; } else if((uint32_t)c < 0x0800) { - *p++ = (char8_t)(uint8_t)((c >> 6) | 0xC0); - *p++ = (char8_t)(uint8_t)((c & 0x3F) | 0x80); + *p++ = (char)(uint8_t)((c >> 6) | 0xC0); + *p++ = (char)(uint8_t)((c & 0x3F) | 0x80); } else if((uint32_t)c < 0x00010000) { - *p++ = (char8_t)(uint8_t)((c >> 12) | 0xE0); - *p++ = (char8_t)(uint8_t)(((c >> 6) & 0x3F) | 0x80); - *p++ = (char8_t)(uint8_t)((c & 0x3F) | 0x80); + *p++ = (char)(uint8_t)((c >> 12) | 0xE0); + *p++ = (char)(uint8_t)(((c >> 6) & 0x3F) | 0x80); + *p++ = (char)(uint8_t)((c & 0x3F) | 0x80); } else { - *p++ = (char8_t)(uint8_t)((c >> 18) | 0xF0); - *p++ = (char8_t)(uint8_t)(((c >> 12) & 0x3F) | 0x80); - *p++ = (char8_t)(uint8_t)(((c >> 6) & 0x3F) | 0x80); - *p++ = (char8_t)(uint8_t)((c & 0x3F) | 0x80); + *p++ = (char)(uint8_t)((c >> 18) | 0xF0); + *p++ = (char)(uint8_t)(((c >> 12) & 0x3F) | 0x80); + *p++ = (char)(uint8_t)(((c >> 6) & 0x3F) | 0x80); + *p++ = (char)(uint8_t)((c & 0x3F) | 0x80); } return p; @@ -489,7 +489,7 @@ EASTDC_API char8_t* UTF8WriteChar(char8_t* p, char32_t c) /// entirely valid UTF8 content. It only trims the string if there is an incomplete UTF8 sequence at the /// end. The resulting string will always be a valid UTF8 string, whereas the input string may not be. /// Returns the strlen of the trimmed string. -size_t UTF8TrimPartialChar(char8_t* pString, size_t nLength) +size_t UTF8TrimPartialChar(char* pString, size_t nLength) { size_t validPos = 0; @@ -516,7 +516,7 @@ size_t UTF8TrimPartialChar(char8_t* pString, size_t nLength) // This function replaces all invalidate UTF8 characters with the user provided // 8-bit replacement. The returned character array is guaranteed null-terminated. // -EASTDC_API char8_t* UTF8ReplaceInvalidChar(const char8_t* pIn, size_t nLength, char8_t* pOut, char8_t replaceWith) +EASTDC_API char* UTF8ReplaceInvalidChar(const char* pIn, size_t nLength, char* pOut, char replaceWith) { size_t validPos = 0; @@ -588,16 +588,16 @@ bool MatchPattern(const CharT* pElement, const CharT* pPattern) // // We go through extra effort below to avoid doing memory allocation in most cases. // -EASTDC_API bool WildcardMatch(const char8_t* pString, const char8_t* pPattern, bool bCaseSensitive) +EASTDC_API bool WildcardMatch(const char* pString, const char* pPattern, bool bCaseSensitive) { if(bCaseSensitive) return MatchPattern(pString, pPattern); else { // Do efficient string conversion to lower case... - char8_t pStringLBuffer[384]; - char8_t* pStringL; - char8_t* pStringLAllocated; + char pStringLBuffer[384]; + char* pStringL; + char* pStringLAllocated; size_t nStringLLength = Strlen(pString); if(nStringLLength >= (sizeof(pStringLBuffer) / sizeof(pStringLBuffer[0]) - 1)) @@ -614,9 +614,9 @@ EASTDC_API bool WildcardMatch(const char8_t* pString, const char8_t* pPattern, b Strlwr(pStringL); // Do efficient pattern conversion to lower case... - char8_t pPatternLBuffer[32]; - char8_t* pPatternL; - char8_t* pPatternLAllocated; + char pPatternLBuffer[32]; + char* pPatternL; + char* pPatternLAllocated; size_t nPatternLLength = Strlen(pPattern); if(nPatternLLength >= (sizeof(pPatternLBuffer) / sizeof(pPatternLBuffer[0]) - 1)) @@ -762,7 +762,7 @@ EASTDC_API bool WildcardMatch(const char32_t* pString, const char32_t* pPattern, ////////////////////////////////////////////////////////////////////////// // GetTextLine // -EASTDC_API const char8_t* GetTextLine(const char8_t* pText, const char8_t* pTextEnd, const char8_t** ppNewText) +EASTDC_API const char* GetTextLine(const char* pText, const char* pTextEnd, const char** ppNewText) { if(pText < pTextEnd) { @@ -843,8 +843,8 @@ EASTDC_API const char32_t* GetTextLine(const char32_t* pText, const char32_t* pT -EASTDC_API bool ParseDelimitedText(const char8_t* pText, const char8_t* pTextEnd, char8_t cDelimiter, - const char8_t*& pToken, const char8_t*& pTokenEnd, const char8_t** ppNewText) +EASTDC_API bool ParseDelimitedText(const char* pText, const char* pTextEnd, char cDelimiter, + const char*& pToken, const char*& pTokenEnd, const char** ppNewText) { int nQuoteLevel = 0; bool bDelimiterFound = false; @@ -1045,18 +1045,18 @@ EASTDC_API bool ParseDelimitedText(const char32_t* pText, const char32_t* pTextE // array must have space for at least twice the amount of bytes // as 'nBinaryDataLength' + 1. // -EASTDC_API void ConvertBinaryDataToASCIIArray(const void* pBinaryData_, size_t nBinaryDataLength, char8_t* pASCIIArray) +EASTDC_API void ConvertBinaryDataToASCIIArray(const void* pBinaryData_, size_t nBinaryDataLength, char* pASCIIArray) { const uint8_t* pBinaryData = (uint8_t*)pBinaryData_; const uint8_t* pEnd = pBinaryData + nBinaryDataLength; while(pBinaryData < pEnd) { - *pASCIIArray = (char8_t)('0' + ((*pBinaryData & 0xf0) >> 4)); // Convert the high byte to a number between 1 and 15. + *pASCIIArray = (char)('0' + ((*pBinaryData & 0xf0) >> 4)); // Convert the high byte to a number between 1 and 15. if(*pASCIIArray > '9') *pASCIIArray += 7; // Convert the ':' to 'A', for example. pASCIIArray++; - *pASCIIArray = (char8_t)('0' + (*pBinaryData & 0x0f)); // Convert the low byte to a number between 1 and 15. + *pASCIIArray = (char)('0' + (*pBinaryData & 0x0f)); // Convert the low byte to a number between 1 and 15. if(*pASCIIArray > '9') *pASCIIArray += 7; // Convert the ':' to 'A', for example. pASCIIArray++; @@ -1117,11 +1117,11 @@ EASTDC_API void ConvertBinaryDataToASCIIArray(const void* pBinaryData_, size_t n // corrupt. We check for this corruption and return false if so, while converting // all corrupt bytes to valid ones. // -EASTDC_API bool ConvertASCIIArrayToBinaryData(const char8_t* pASCIIArray, size_t nASCIIArrayLength, void* pBinaryData) +EASTDC_API bool ConvertASCIIArrayToBinaryData(const char* pASCIIArray, size_t nASCIIArrayLength, void* pBinaryData) { uint8_t* pBinaryData8 = (uint8_t*)pBinaryData; - const char8_t* pEnd = pASCIIArray + nASCIIArrayLength; - char8_t cTemp; + const char* pEnd = pASCIIArray + nASCIIArrayLength; + char cTemp; bool bReturnValue(true); while(pASCIIArray < pEnd) @@ -1283,8 +1283,8 @@ EASTDC_API bool ConvertASCIIArrayToBinaryData(const char32_t* pASCIIArray, size_ ////////////////////////////////////////////////////////////////////////////// // SplitTokenDelimited (8 bit version) // -EASTDC_API bool SplitTokenDelimited(const char8_t* pSource, size_t nSourceLength, char8_t cDelimiter, - char8_t* pToken, size_t nTokenLength, const char8_t** ppNewSource) +EASTDC_API bool SplitTokenDelimited(const char* pSource, size_t nSourceLength, char cDelimiter, + char* pToken, size_t nTokenLength, const char** ppNewSource) { // terminate the token (so it appears empty if we don't find anything) if(pToken && nTokenLength) @@ -1295,7 +1295,7 @@ EASTDC_API bool SplitTokenDelimited(const char8_t* pSource, size_t nSourceLength // look for the delimiter for(size_t i = 0; i < nSourceLength && *pSource; i++) { - const char8_t cTemp(*pSource); + const char cTemp(*pSource); // update new source pointer if present if(ppNewSource) @@ -1419,8 +1419,8 @@ EASTDC_API bool SplitTokenDelimited(const char32_t* pSource, size_t nSourceLengt ////////////////////////////////////////////////////////////////////////////// // SplitTokenSeparated (8 bit version) // -EASTDC_API bool SplitTokenSeparated(const char8_t* pSource, size_t nSourceLength, char8_t c, - char8_t* pToken, size_t nTokenLength, const char8_t** ppNewSource) +EASTDC_API bool SplitTokenSeparated(const char* pSource, size_t nSourceLength, char c, + char* pToken, size_t nTokenLength, const char** ppNewSource) { // terminate the token (so it appears empty if we don't find anything) @@ -1440,7 +1440,7 @@ EASTDC_API bool SplitTokenSeparated(const char8_t* pSource, size_t nSourceLength for(size_t i = 0; i < nSourceLength; i++) { // get the character - const char8_t cTemp(*pSource); + const char cTemp(*pSource); // quit if we found the terminating null character if(cTemp != '\0') diff --git a/test/source/TestCType.cpp b/test/source/TestCType.cpp index 9d5a7ac..721caa9 100644 --- a/test/source/TestCType.cpp +++ b/test/source/TestCType.cpp @@ -24,12 +24,13 @@ int TestCType() EATEST_VERIFY((Is##category((char##type##_t)c) != 0) == positive);\ } + // Make sure all chars are accepted int32_t i; - char8_t n8; + char n8; char16_t n16; int n32; - char8_t c8; + char c8; char16_t c16; for(c8 = INT8_MIN, i = INT8_MIN; i <= INT8_MAX; ++c8, ++i) @@ -98,20 +99,20 @@ int TestCType() } // ********************* alnum - ISCHAR_CATEGORY_TEST(8, alnum, '0', '9', true); - ISCHAR_CATEGORY_TEST(8, alnum, 'a', 'z', true); - ISCHAR_CATEGORY_TEST(8, alnum, 'A', 'Z', true); - ISCHAR_CATEGORY_TEST(8, alnum, '\x0', '\x15', false); + // ISCHAR_CATEGORY_TEST(8, alnum, '0', '9', true); + // ISCHAR_CATEGORY_TEST(8, alnum, 'a', 'z', true); + // ISCHAR_CATEGORY_TEST(8, alnum, 'A', 'Z', true); + // ISCHAR_CATEGORY_TEST(8, alnum, '\x0', '\x15', false); ISCHAR_CATEGORY_TEST(16, alnum, '0', '9', true); ISCHAR_CATEGORY_TEST(16, alnum, 'a', 'z', true); ISCHAR_CATEGORY_TEST(16, alnum, 'A', 'Z', true); // ********************* alpha - ISCHAR_CATEGORY_TEST(8, alpha, '0', '9', false); - ISCHAR_CATEGORY_TEST(8, alpha, 'a', 'z', true); - ISCHAR_CATEGORY_TEST(8, alpha, 'A', 'Z', true); - ISCHAR_CATEGORY_TEST(8, alpha, '\x0', '\x15', false); + // ISCHAR_CATEGORY_TEST(8, alpha, '0', '9', false); + // ISCHAR_CATEGORY_TEST(8, alpha, 'a', 'z', true); + // ISCHAR_CATEGORY_TEST(8, alpha, 'A', 'Z', true); + // ISCHAR_CATEGORY_TEST(8, alpha, '\x0', '\x15', false); ISCHAR_CATEGORY_TEST(16, alpha, '0', '9', false); ISCHAR_CATEGORY_TEST(16, alpha, 'a', 'z', true); @@ -119,10 +120,10 @@ int TestCType() ISCHAR_CATEGORY_TEST(16, alpha, '(', '('+10, false); // digit - ISCHAR_CATEGORY_TEST(8, digit, '0', '9', true); - ISCHAR_CATEGORY_TEST(8, digit, 'a', 'z', false); - ISCHAR_CATEGORY_TEST(8, digit, 'A', 'Z', false); - ISCHAR_CATEGORY_TEST(8, digit, '\x0', '\x15', false); + // ISCHAR_CATEGORY_TEST(8, digit, '0', '9', true); + // ISCHAR_CATEGORY_TEST(8, digit, 'a', 'z', false); + // ISCHAR_CATEGORY_TEST(8, digit, 'A', 'Z', false); + // ISCHAR_CATEGORY_TEST(8, digit, '\x0', '\x15', false); ISCHAR_CATEGORY_TEST(16, digit, '0', '9', true); ISCHAR_CATEGORY_TEST(16, digit, 'a', 'z', false); @@ -130,10 +131,10 @@ int TestCType() ISCHAR_CATEGORY_TEST(16, digit, '\x70', '\x71', false); // xdigit - ISCHAR_CATEGORY_TEST(8, xdigit, '0', '9', true); - ISCHAR_CATEGORY_TEST(8, xdigit, 'a', 'f', true); - ISCHAR_CATEGORY_TEST(8, xdigit, 'A', 'F', true); - ISCHAR_CATEGORY_TEST(8, xdigit, '\x0', '\x15', false); + // ISCHAR_CATEGORY_TEST(8, xdigit, '0', '9', true); + // ISCHAR_CATEGORY_TEST(8, xdigit, 'a', 'f', true); + // ISCHAR_CATEGORY_TEST(8, xdigit, 'A', 'F', true); + // ISCHAR_CATEGORY_TEST(8, xdigit, '\x0', '\x15', false); ISCHAR_CATEGORY_TEST(16, xdigit, '0', '9', true); ISCHAR_CATEGORY_TEST(16, xdigit, 'a', 'f', true); @@ -141,18 +142,18 @@ int TestCType() ISCHAR_CATEGORY_TEST(16, xdigit, 'z'+1, 'z'+60, false); // graph - ISCHAR_CATEGORY_TEST(8, graph, '\x21','\x7e', true); - ISCHAR_CATEGORY_TEST(8, graph, '\x0', '\x20', false); + // ISCHAR_CATEGORY_TEST(8, graph, '\x21','\x7e', true); + // ISCHAR_CATEGORY_TEST(8, graph, '\x0', '\x20', false); ISCHAR_CATEGORY_TEST(16, graph, '!', '!'+14, true); ISCHAR_CATEGORY_TEST(16, graph, '0', 'z', true); ISCHAR_CATEGORY_TEST(16, graph, '\x0', '\x20', false); // lower - ISCHAR_CATEGORY_TEST(8, lower, '0', '9', false); - ISCHAR_CATEGORY_TEST(8, lower, 'a', 'z', true); - ISCHAR_CATEGORY_TEST(8, lower, 'A', 'Z', false); - ISCHAR_CATEGORY_TEST(8, lower, '\x0', '\x15', false); + // ISCHAR_CATEGORY_TEST(8, lower, '0', '9', false); + // ISCHAR_CATEGORY_TEST(8, lower, 'a', 'z', true); + // ISCHAR_CATEGORY_TEST(8, lower, 'A', 'Z', false); + // ISCHAR_CATEGORY_TEST(8, lower, '\x0', '\x15', false); ISCHAR_CATEGORY_TEST(16, lower, '0', '9', false); ISCHAR_CATEGORY_TEST(16, lower, 'a', 'z', true); @@ -160,10 +161,10 @@ int TestCType() ISCHAR_CATEGORY_TEST(16, lower, '!', '!'+14, false); // upper - ISCHAR_CATEGORY_TEST(8, upper, '0', '9', false); - ISCHAR_CATEGORY_TEST(8, upper, 'a', 'z', false); - ISCHAR_CATEGORY_TEST(8, upper, 'A', 'Z', true); - ISCHAR_CATEGORY_TEST(8, upper, '\x0', '\x15', false); + // ISCHAR_CATEGORY_TEST(8, upper, '0', '9', false); + // ISCHAR_CATEGORY_TEST(8, upper, 'a', 'z', false); + // ISCHAR_CATEGORY_TEST(8, upper, 'A', 'Z', true); + // ISCHAR_CATEGORY_TEST(8, upper, '\x0', '\x15', false); ISCHAR_CATEGORY_TEST(16, upper, '0', '9', false); ISCHAR_CATEGORY_TEST(16, upper, 'a', 'z', false); @@ -171,14 +172,14 @@ int TestCType() ISCHAR_CATEGORY_TEST(16, upper, '!', '!'+14, false); // punct - ISCHAR_CATEGORY_TEST(8, punct, '0', '9', false); - ISCHAR_CATEGORY_TEST(8, punct, 'a', 'z', false); - ISCHAR_CATEGORY_TEST(8, punct, 'A', 'Z', false); - ISCHAR_CATEGORY_TEST(8, punct, '\x0', '\x15', false); - ISCHAR_CATEGORY_TEST(8, punct, '!', '!', true); - ISCHAR_CATEGORY_TEST(8, punct, '?', '?', true); - ISCHAR_CATEGORY_TEST(8, punct, '.', '.', true); - ISCHAR_CATEGORY_TEST(8, punct, ',', ',', true); + // ISCHAR_CATEGORY_TEST(8, punct, '0', '9', false); + // ISCHAR_CATEGORY_TEST(8, punct, 'a', 'z', false); + // ISCHAR_CATEGORY_TEST(8, punct, 'A', 'Z', false); + // ISCHAR_CATEGORY_TEST(8, punct, '\x0', '\x15', false); + // ISCHAR_CATEGORY_TEST(8, punct, '!', '!', true); + // ISCHAR_CATEGORY_TEST(8, punct, '?', '?', true); + // ISCHAR_CATEGORY_TEST(8, punct, '.', '.', true); + // ISCHAR_CATEGORY_TEST(8, punct, ',', ',', true); ISCHAR_CATEGORY_TEST(16, punct, '0', '9', false); ISCHAR_CATEGORY_TEST(16, punct, 'a', 'z', false); @@ -190,24 +191,24 @@ int TestCType() ISCHAR_CATEGORY_TEST(16, punct, ':', ';', true); // space - ISCHAR_CATEGORY_TEST(8, space, '0', '9', false); - ISCHAR_CATEGORY_TEST(8, space, ' ', ' ', true); - ISCHAR_CATEGORY_TEST(8, space, '\x0a', '\x0a', true); + // ISCHAR_CATEGORY_TEST(8, space, '0', '9', false); + // ISCHAR_CATEGORY_TEST(8, space, ' ', ' ', true); + // ISCHAR_CATEGORY_TEST(8, space, '\x0a', '\x0a', true); ISCHAR_CATEGORY_TEST(16, space, 'a', 'z', false); ISCHAR_CATEGORY_TEST(16, space, '\x09', '\x09', true); ISCHAR_CATEGORY_TEST(16, space, '\x0d', '\x0d', true); // cntrl - ISCHAR_CATEGORY_TEST(8, cntrl, 0, '\x1f', true); - ISCHAR_CATEGORY_TEST(8, cntrl, '\x7f', '\x7f', true); + // ISCHAR_CATEGORY_TEST(8, cntrl, 0, '\x1f', true); + // ISCHAR_CATEGORY_TEST(8, cntrl, '\x7f', '\x7f', true); ISCHAR_CATEGORY_TEST(16, cntrl, 0, '\x1f', true); ISCHAR_CATEGORY_TEST(16, cntrl, '\x7f', '\x7f', true); // ascii - ISCHAR_CATEGORY_TEST(8, ascii, '\x0', '\x7f', true); - ISCHAR_CATEGORY_TEST(8, ascii, '\x80', '\xff', false); + // ISCHAR_CATEGORY_TEST(8, ascii, '\x0', '\x7f', true); + // ISCHAR_CATEGORY_TEST(8, ascii, '\x80', '\xff', false); ISCHAR_CATEGORY_TEST(16, ascii, '\x0', '\x7f', true); ISCHAR_CATEGORY_TEST(16, ascii, '\x80', '\xff', false); @@ -216,8 +217,8 @@ int TestCType() // Toupper8 / Tolower8 / Toupper16 Tolower16 for (int c = 'a'; c < 'z'; ++c) { - EATEST_VERIFY(Toupper((char8_t)c) == 'A' + c - 'a'); - EATEST_VERIFY(Tolower((char8_t)('A' + c - 'a')) == (char8_t)c); + EATEST_VERIFY(Toupper((char)c) == 'A' + c - 'a'); + EATEST_VERIFY(Tolower((char)('A' + c - 'a')) == (char)c); EATEST_VERIFY(Toupper((char16_t)c) == char16_t('A' + c - 'a')); EATEST_VERIFY(Tolower((char16_t)('A' + c - 'a')) == char16_t((char16_t)c)); diff --git a/test/source/TestDateTime.cpp b/test/source/TestDateTime.cpp index 534904a..2713fca 100644 --- a/test/source/TestDateTime.cpp +++ b/test/source/TestDateTime.cpp @@ -598,7 +598,7 @@ int TestDateTime() char* pBuffer = new char[kBufferSize]; tm tmValue1, tmValue2; size_t n; - char8_t* p; + char* p; { DateTime dt(1999, 12, 31, 23, 59, 58); @@ -636,8 +636,8 @@ int TestDateTime() memcpy(&tmValue2, &tmValue1, sizeof(tmValue2)); - const char8_t* kFormat = "%t %t%%%n%n%%"; - const char8_t* kResult = "\t \t%\n\n%"; + const char* kFormat = "%t %t%%%n%n%%"; + const char* kResult = "\t \t%\n\n%"; n = Strftime(pBuffer, kBufferSize, kFormat, &tmValue1, NULL); EATEST_VERIFY((n == Strlen(kResult)) && (Strcmp(pBuffer, kResult) == 0)); EATEST_VERIFY(memcmp(&tmValue1, &tmValue2, sizeof(tmValue2)) == 0); // Verify that tmValue1 was not written to. @@ -650,7 +650,7 @@ int TestDateTime() // %a Replaced by the locale's abbreviated weekday name. [ tm_wday] // %A Replaced by the locale's full weekday name. [ tm_wday] - const char8_t* kExpectedResults[7] = + const char* kExpectedResults[7] = { "Sun | Sun | Sunday | Sunday", "Mon | Mon | Monday | Monday", @@ -684,7 +684,7 @@ int TestDateTime() // %h Equivalent to %b. [ tm_mon] // %m Replaced by the month as a decimal number [01,12]. [ tm_mon] - const char8_t* kExpectedResults[12] = + const char* kExpectedResults[12] = { "Jan | Jan | January | January | Jan | Jan | 01 | 1", "Feb | Feb | February | February | Feb | Feb | 02 | 2", @@ -925,7 +925,7 @@ int TestDateTime() 2100, }; - const char8_t* kExpectedResults[5] = + const char* kExpectedResults[5] = { "19 | 19", "20 | 20", @@ -973,7 +973,7 @@ int TestDateTime() { // %D Equivalent to %m/%d/%y. [ tm_mon, tm_mday, tm_year] - const char8_t* kExpectedResults[12] = + const char* kExpectedResults[12] = { "01/01/66", "02/02/67", @@ -1026,7 +1026,7 @@ int TestDateTime() { // %F Equivalent to %Y - %m - %d (the ISO 8601:2000 standard date format). [ tm_year, tm_mon, tm_mday] - const char8_t* kExpectedResults[12] = + const char* kExpectedResults[12] = { "2001-01-01", "2002-02-02", @@ -1119,7 +1119,7 @@ int TestDateTime() { // %j Replaced by the day of the year as a decimal number [001,366]. [ tm_yday] - const char8_t* kExpectedResults[4] = + const char* kExpectedResults[4] = { "366 | 366", "365 | 365", @@ -1169,7 +1169,7 @@ int TestDateTime() // %r Replaced by the time in a.m. and p.m. notation; [CX] [Option Start] in the POSIX locale this shall be equivalent to %I : %M : %S %p. [Option End] [ tm_hour, tm_min, tm_sec] // %R Replaced by the time in 24-hour notation ( %H : %M ). [ tm_hour, tm_min] // %T Replaced by the time ( %H : %M : %S ). [ tm_hour, tm_min, tm_sec] - const char8_t* kExpectedResults[8] = + const char* kExpectedResults[8] = { "AM", "10:11:12 AM", "10:11", "10:11:12", "PM", "01:02:03 PM", "13:02", "13:02:03", @@ -1474,7 +1474,7 @@ int TestDateTime() 1969, }; - const char8_t* kExpectedResults[5] = + const char* kExpectedResults[5] = { "00 | 0 | 2000", "01 | 1 | 2001", diff --git a/test/source/TestHash.cpp b/test/source/TestHash.cpp index 37b72d8..a557ff4 100644 --- a/test/source/TestHash.cpp +++ b/test/source/TestHash.cpp @@ -92,8 +92,8 @@ int TestHash() uint8_t* pDataA = new uint8_t[kDataLength]; uint8_t* pDataB = new uint8_t[kDataLength]; - char8_t* pData8A = new char8_t[kDataLength]; - char8_t* pData8B = new char8_t[kDataLength]; + char* pData8A = new char[kDataLength]; + char* pData8B = new char[kDataLength]; char16_t* pData16A = new char16_t[kDataLength]; char16_t* pData16B = new char16_t[kDataLength]; char32_t* pData32A = new char32_t[kDataLength]; @@ -106,8 +106,8 @@ int TestHash() pDataA[i] = (uint8_t) c; pDataB[i] = (uint8_t) c; - pData8A[i] = (char8_t) c; - pData8B[i] = (char8_t) c; + pData8A[i] = (char) c; + pData8B[i] = (char) c; pData16A[i] = (char16_t)c; pData16B[i] = (char16_t)c; pData32A[i] = (char32_t)c; diff --git a/test/source/TestMemory.cpp b/test/source/TestMemory.cpp index a8f9add..cd559f5 100644 --- a/test/source/TestMemory.cpp +++ b/test/source/TestMemory.cpp @@ -335,8 +335,8 @@ static int TestMemset() { // To do: We need a more extensive test. - char8_t buffer[2000]; - const char8_t* pattern = "012345678"; + char buffer[2000]; + const char* pattern = "012345678"; size_t sl = Strlen(pattern); EATEST_VERIFY(buffer == MemsetN(buffer, pattern, sl, 2000)); @@ -603,25 +603,14 @@ static int TestMemchr() int nErrorCount = 0; { // Memchr8 - const char8_t* const s = "qwertyuiopASDFGHJKL:!@#$%^&*,=/"; + const char* const s = "qwertyuiopASDFGHJKL:!@#$%^&*,=/"; - EATEST_VERIFY((char8_t*)Memchr(s, (char8_t)'q', Strlen(s)) - s == 0); - EATEST_VERIFY((char8_t*)Memchr(s, (char8_t)'F', Strlen(s)) - s == 13); - EATEST_VERIFY((char8_t*)Memchr(s, (char8_t)':', Strlen(s)) - s == 19); - EATEST_VERIFY((char8_t*)Memchr(s, (char8_t)'&', Strlen(s)) - s == 26); + EATEST_VERIFY((char*)Memchr(s, (char)'q', Strlen(s)) - s == 0); + EATEST_VERIFY((char*)Memchr(s, (char)'F', Strlen(s)) - s == 13); + EATEST_VERIFY((char*)Memchr(s, (char)':', Strlen(s)) - s == 19); + EATEST_VERIFY((char*)Memchr(s, (char)'&', Strlen(s)) - s == 26); } - #if EASTDC_MEMCHR16_ENABLED && defined(EA_CHAR16) - { // Memchr16 - const char16_t* const s = EA_CHAR16("qwertyuiopASDFGHJKL:!@#$%^&*,=/"); - - EATEST_VERIFY((char16_t*)Memchr(s, (char16_t)'q', Strlen(s)) - s == 0); - EATEST_VERIFY((char16_t*)Memchr(s, (char16_t)'F', Strlen(s)) - s == 13); - EATEST_VERIFY((char16_t*)Memchr(s, (char16_t)':', Strlen(s)) - s == 19); - EATEST_VERIFY((char16_t*)Memchr(s, (char16_t)'&', Strlen(s)) - s == 26); - } - #endif - return nErrorCount; } @@ -633,9 +622,9 @@ static int TestMemcmp() int nErrorCount = 0; { // Memcmp8 - char8_t buffer1[] = "01234567a"; - char8_t buffer2[] = "01234567b"; - char8_t buffer3[] = "01234567c"; + char buffer1[] = "01234567a"; + char buffer2[] = "01234567b"; + char buffer3[] = "01234567c"; EATEST_VERIFY(Memcmp(buffer1, buffer1, 9) == 0); EATEST_VERIFY(Memcmp(buffer2, buffer1, 9) > 0); @@ -669,7 +658,7 @@ static int TestMemmem() int nErrorCount = 0; const size_t kSize = 37; - const char8_t buffer1[kSize] = "abcdefghijklmnopqrstuvwxyz0123456789"; + const char buffer1[kSize] = "abcdefghijklmnopqrstuvwxyz0123456789"; EATEST_VERIFY(Memmem(buffer1, 0, "", 0) == NULL); // An empty haystack always results in NULL, regardless of the needle. EATEST_VERIFY(Memmem(buffer1, kSize, "", 0) == buffer1); // Otherwise, an empty needle results in success. @@ -698,8 +687,8 @@ static int TestMemcpy() int nErrorCount = 0; { // MemcpyC - char8_t buffer1[] = " "; - char8_t buffer2[] = "01234567b"; + char buffer1[] = " "; + char buffer2[] = "01234567b"; EATEST_VERIFY(buffer1 == MemcpyC(buffer1, buffer2, 9)); EATEST_VERIFY(Memcmp(buffer2, buffer1, 9) == 0); @@ -716,7 +705,7 @@ static int TestMemcpy() #endif - { // char8_t* MemcpyC(void* pDestination, const void* pSource, size_t nByteCount); + { // char* MemcpyC(void* pDestination, const void* pSource, size_t nByteCount); EA::StdC::Random r; const void* pCheck; @@ -754,7 +743,7 @@ static int TestMemcpy() } - { // char8_t* Memcpy128(void* pDestination, const void* pSource, size_t nByteCount); + { // char* Memcpy128(void* pDestination, const void* pSource, size_t nByteCount); EA::StdC::Stopwatch stopwatch1(EA::StdC::Stopwatch::kUnitsCPUCycles); EA::StdC::Stopwatch stopwatch2(EA::StdC::Stopwatch::kUnitsCPUCycles); @@ -816,7 +805,7 @@ static int TestMemcpy() } } - { // char8_t* Memcpy128C(void* pDestination, const void* pSource, size_t nByteCount); + { // char* Memcpy128C(void* pDestination, const void* pSource, size_t nByteCount); for(size_t i = 0; i < 50; i++) { const size_t copySize = i * 128; @@ -855,13 +844,13 @@ static int TestMemmove() int nErrorCount = 0; { // Memmove8 - char8_t buffer1[] = "..........."; - char8_t buffer2[] = ".......0123"; - char8_t buffer3[] = "0123......."; + char buffer1[] = "..........."; + char buffer2[] = ".......0123"; + char buffer3[] = "0123......."; EATEST_VERIFY(buffer1 == MemmoveC(buffer1, buffer2, Strlen(buffer2))); EATEST_VERIFY(memcmp(buffer1, buffer2, Strlen(buffer2)) == 0); - EATEST_VERIFY(memset(buffer1, (char8_t )0, Strlen(buffer1)) != NULL); + EATEST_VERIFY(memset(buffer1, (char )0, Strlen(buffer1)) != NULL); EATEST_VERIFY(buffer1 == MemmoveC(buffer1, buffer2+7, Strlen(buffer2) - 7)); EATEST_VERIFY(memcmp(buffer1, buffer2+7, Strlen(buffer2) - 7) == 0); @@ -914,10 +903,10 @@ static int TestTimingSafe() // bool TimingSafeMemIsClear(const void* p, size_t n); { // Basic accuracy tests. - char8_t buffer1[] = "01234567a"; - char8_t buffer2[] = "01234567b"; - char8_t buffer3[] = "01234567c"; - char8_t buffer4[] = "\0\0\0\0\0\0\0\0\0"; + char buffer1[] = "01234567a"; + char buffer2[] = "01234567b"; + char buffer3[] = "01234567c"; + char buffer4[] = "\0\0\0\0\0\0\0\0\0"; EATEST_VERIFY(TimingSafeMemcmp(buffer1, buffer1, 0) == Memcmp(buffer1, buffer1, 0)); EATEST_VERIFY(TimingSafeMemcmp(buffer2, buffer1, 9) == Memcmp(buffer2, buffer1, 9)); diff --git a/test/source/TestProcess.cpp b/test/source/TestProcess.cpp index 985df99..5997870 100644 --- a/test/source/TestProcess.cpp +++ b/test/source/TestProcess.cpp @@ -20,7 +20,7 @@ #if defined(EA_PLATFORM_WINDOWS) && EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP) - template // T is one of char8_t, char16_t, char32_t. + template // T is one of char, char16_t, char32_t. static void TestEnvironmentVar(int& nErrorCount) { using namespace EA::StdC; @@ -73,14 +73,14 @@ nRequiredStrlen = GetEnvironmentVar(name, valueOut, EAArrayCount(valueOut)); EATEST_VERIFY((nRequiredStrlen == 17) && (Strcmp(valueIn, valueOut) == 0)); - // Verify that GetEnvironmentVar(T) yields the same result as GetEnvironmentVar(char8_t) (T may be char16_t). - char8_t valueOut8[32]; + // Verify that GetEnvironmentVar(T) yields the same result as GetEnvironmentVar(char) (T may be char16_t). + char valueOut8[32]; T valueOutT[32]; nRequiredStrlen = GetEnvironmentVar("NameExisting", valueOut8, EAArrayCount(valueOut8)); - Strlcpy(valueOutT, valueOut8, EAArrayCount(valueOutT)); // Need to convert char8_t to T, as Strcmp only exists for like types. + Strlcpy(valueOutT, valueOut8, EAArrayCount(valueOutT)); // Need to convert char to T, as Strcmp only exists for like types. EATEST_VERIFY((nRequiredStrlen == 17) && (Strcmp(valueOut, valueOutT) == 0)); - // Verify that GetEnvironmentVar(T) yields the same result as GetEnvironmentVar(char16_t) (T may be char8_t). + // Verify that GetEnvironmentVar(T) yields the same result as GetEnvironmentVar(char16_t) (T may be char). char16_t name16[32]; char16_t valueOut16[32]; Strlcpy(name16, name, EAArrayCount(name16)); @@ -99,17 +99,17 @@ int TestProcess() EA::UnitTest::Report("TestProcess\n"); { - // size_t GetCurrentProcessPath(char8_t* pPath); + // size_t GetCurrentProcessPath(char* pPath); // size_t GetCurrentProcessPath(char16_t* pPath); // size_t GetCurrentProcessPath(char32_t* pPath); - // size_t GetCurrentProcessDirectory(char8_t* pDirectory); + // size_t GetCurrentProcessDirectory(char* pDirectory); // size_t GetCurrentProcessDirectory(char16_t* pDirectory); // size_t GetCurrentProcessDirectory(char32_t* pDirectory); // Currently we have known support for Windows. With other platforms support is inconsistent. #if EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP) || defined(EA_PLATFORM_APPLE) || defined(EA_PLATFORM_LINUX) || (defined(EA_PLATFORM_SONY) && EA_SCEDBG_ENABLED) char16_t path16[EA::StdC::kMaxPathLength]; - char8_t path8[EA::StdC::kMaxPathLength]; + char path8[EA::StdC::kMaxPathLength]; size_t n; size_t processPathLen; @@ -178,15 +178,15 @@ int TestProcess() } { - // size_t GetEnvironmentVar(const char8_t* pName, char8_t* pValue, size_t valueCapacity); + // size_t GetEnvironmentVar(const char* pName, char* pValue, size_t valueCapacity); // size_t GetEnvironmentVar(const char16_t* pName, char16_t* pValue, size_t valueCapacity); // size_t GetEnvironmentVar(const char32_t* pName, char32_t* pValue, size_t valueCapacity); - // bool SetEnvironmentVar(const char8_t* pName, const char8_t* pValue); + // bool SetEnvironmentVar(const char* pName, const char* pValue); // bool SetEnvironmentVar(const char16_t* pName, const char16_t* pValue); // bool SetEnvironmentVar(const char32_t* pName, const char32_t* pValue); #if defined(EA_PLATFORM_WINDOWS) && EA_WINAPI_FAMILY_PARTITION(EA_WINAPI_PARTITION_DESKTOP) // To do: Enable this for other platforms when possible. - TestEnvironmentVar(nErrorCount); + TestEnvironmentVar(nErrorCount); TestEnvironmentVar(nErrorCount); //TestEnvironmentVar(nErrorCount); // Doesn't yet exist. #endif @@ -195,16 +195,16 @@ int TestProcess() /* { // int Spawn(const char16_t* pPath, const char16_t* const* pArgumentArray, bool wait = false); - // int Spawn(const char8_t* pPath, const char8_t* const* pArgumentArray, bool wait = false); + // int Spawn(const char* pPath, const char* const* pArgumentArray, bool wait = false); // int ExecuteShellCommand(const char16_t* pCommand); - // int ExecuteShellCommand(const char8_t* pCommand); + // int ExecuteShellCommand(const char* pCommand); // bool SearchEnvironmentPath(const char16_t* pFileName, char16_t* pPath, const char16_t* pEnvironmentVar = NULL); - // bool SearchEnvironmentPath(const char8_t* pFileName, char8_t* pPath, const char8_t* pEnvironmentVar = NULL); + // bool SearchEnvironmentPath(const char* pFileName, char* pPath, const char* pEnvironmentVar = NULL); // bool OpenFile(const char16_t* pPath); // e.g. http://www.bozo.com/somefile.html - // bool OpenFile(const char8_t* pPath); // e.g. /system/settings/somefile.txt + // bool OpenFile(const char* pPath); // e.g. /system/settings/somefile.txt } */ diff --git a/test/source/TestScanf.cpp b/test/source/TestScanf.cpp index 99609bb..652742a 100644 --- a/test/source/TestScanf.cpp +++ b/test/source/TestScanf.cpp @@ -67,10 +67,10 @@ struct Values uint64_t uint64_[8]; //EA::StdC::int128_t int128_[8]; // int128_t has constructors and so is not a POD and cannot be part of the Values union. //EA::StdC::uint128_t uint128_[8]; - char8_t char8_[8]; + char char8_[8]; char16_t char16_[8]; char32_t char32_[8]; - char8_t str8_[8][64]; + char str8_[8][64]; char16_t str16_[8][64]; char32_t str32_[8][64]; wchar_t strw_[8][64]; @@ -95,7 +95,7 @@ struct Values uint32_t Values::assertCount_ = 0; -static int TestCRTVsscanf(const char8_t* pBuffer, const char8_t* pFormat, ...) +static int TestCRTVsscanf(const char* pBuffer, const char* pFormat, ...) { va_list vList; va_start(vList, pFormat); @@ -460,12 +460,12 @@ static int TestScanfMisc() } { // String tests - // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char8_t, char16_t, char32_t) - // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char8_t, char16_t, char32_t) - // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char8_t, char16_t, char32_t) - // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char8_t, char16_t, char32_t) + // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char, char16_t, char32_t) + // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char, char16_t, char32_t) + // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char, char16_t, char32_t) + // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char, char16_t, char32_t) - { // char8_t + { // char v.Clear(); n = Sscanf("a b c d e f", "%hc %c %lc %I8c %I16c %I32c", &v.char_[0], &v.char_[1], &v.wchar_[0], &v.char8_[0], &v.char16_[0], &v.char32_[0]); EATEST_VERIFY(n == 6); @@ -499,7 +499,7 @@ static int TestScanfMisc() { // char16_t v.Clear(); - #if EASCANF_MS_STYLE_S_FORMAT // Microsoft style means that the meanings of S/C and s/c are reversed for non-char8_t Sprintf. + #if EASCANF_MS_STYLE_S_FORMAT // Microsoft style means that the meanings of S/C and s/c are reversed for non-char Sprintf. n = Sscanf(EA_CHAR16("a b c d e f"), EA_CHAR16("%hc %c %lc %I8c %I16c %I32c"), &v.char_[0], &v.wchar_[0], &v.wchar_[1], &v.char8_[0], &v.char16_[0], &v.char32_[0]); EATEST_VERIFY(n == 6); EATEST_VERIFY((v.char_[0] == 'a') && (v.wchar_[0] == 'b') && (v.wchar_[1] == 'c') && (v.char8_[0] == 'd') && (v.char16_[0] == 'e') && (v.char32_[0] == 'f')); @@ -565,7 +565,7 @@ static int TestScanfMisc() { // char32_t v.Clear(); - #if EASCANF_MS_STYLE_S_FORMAT // Microsoft style means that the meanings of S/C and s/c are reversed for non-char8_t Sprintf. + #if EASCANF_MS_STYLE_S_FORMAT // Microsoft style means that the meanings of S/C and s/c are reversed for non-char Sprintf. n = Sscanf(EA_CHAR32("a b c d e f"), EA_CHAR32("%hc %c %lc %I8c %I16c %I32c"), &v.char_[0], &v.wchar_[0], &v.wchar_[1], &v.char8_[0], &v.char16_[0], &v.char32_[0]); EATEST_VERIFY(n == 6); EATEST_VERIFY((v.char_[0] == 'a') && (v.wchar_[0] == 'b') && (v.wchar_[1] == 'c') && (v.char8_[0] == 'd') && (v.char16_[0] == 'e') && (v.char32_[0] == 'f')); @@ -2118,12 +2118,12 @@ static int TestScanfMisc() { v.Clear(); - v.char8_[0] = (char8_t)(uint8_t)0xdd; + v.char8_[0] = (char)(uint8_t)0xdd; n = Sscanf("10:11", "%d:%d%c", &v.int_[0], &v.int_[1], &v.char8_[0]); EATEST_VERIFY(n == 2); EATEST_VERIFY(v.int_[0] == 10); EATEST_VERIFY(v.int_[1] == 11); - EATEST_VERIFY(v.char8_[0] == (char8_t)(uint8_t)0xdd); + EATEST_VERIFY(v.char8_[0] == (char)(uint8_t)0xdd); v.Clear(); #if EASCANF_MS_STYLE_S_FORMAT @@ -2131,9 +2131,9 @@ static int TestScanfMisc() n = Sscanf(EA_CHAR16("10:11"), EA_CHAR16("%d:%d%c"), &v.int_[0], &v.int_[1], &v.wchar_[0]); EATEST_VERIFY(v.wchar_[0] == 0xdd); #else - v.char8_[0] = (char8_t)(uint8_t)0xdd; + v.char8_[0] = (char)(uint8_t)0xdd; n = Sscanf(EA_CHAR16("10:11"), EA_CHAR16("%d:%d%c"), &v.int_[0], &v.int_[1], &v.char8_[0]); - EATEST_VERIFY(v.char8_[0] == (char8_t)(uint8_t)0xdd); + EATEST_VERIFY(v.char8_[0] == (char)(uint8_t)0xdd); #endif EATEST_VERIFY(n == 2); EATEST_VERIFY(v.int_[0] == 10); @@ -2145,9 +2145,9 @@ static int TestScanfMisc() n = Sscanf(EA_CHAR32("10:11"), EA_CHAR32("%d:%d%c"), &v.int_[0], &v.int_[1], &v.wchar_[0]); EATEST_VERIFY(v.wchar_[0] == 0xdd); #else - v.char8_[0] = (char8_t)(uint8_t)0xdd; + v.char8_[0] = (char)(uint8_t)0xdd; n = Sscanf(EA_CHAR32("10:11"), EA_CHAR32("%d:%d%c"), &v.int_[0], &v.int_[1], &v.char8_[0]); - EATEST_VERIFY(v.char8_[0] == (char8_t)(uint8_t)0xdd); + EATEST_VERIFY(v.char8_[0] == (char)(uint8_t)0xdd); #endif EATEST_VERIFY(n == 2); EATEST_VERIFY(v.int_[0] == 10); @@ -2361,7 +2361,7 @@ static int TestScanfUnusual() EATEST_VERIFY((uintptr_t)v.voidptr_[0] == 0xffffffff); } - { // Make sure we support explicit char8_t strings. + { // Make sure we support explicit char strings. v.Clear(); n = Sscanf("2.0", "%hs", v.str8_[0]); EATEST_VERIFY(n == 1); @@ -2395,7 +2395,7 @@ static int TestScanfUnusual() EATEST_VERIFY(Strcmp(v.strw_[0], EA_WCHAR("2.0")) == 0); } - { // Make sure we support explicit char8_t chars. + { // Make sure we support explicit char chars. v.Clear(); n = Sscanf("2.0", "%hc", &v.char8_[0]); EATEST_VERIFY(n == 1); @@ -2669,10 +2669,10 @@ static int TestScanfVariants() // To do: Implement some of these: /* - EASTDC_API int Cscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, ...); - EASTDC_API int Fscanf(FILE* pFile, const char8_t* pFormat, ...); - EASTDC_API int Scanf(const char8_t* pFormat, ...); - EASTDC_API int Sscanf(const char8_t* pTextBuffer, const char8_t* pFormat, ...); + EASTDC_API int Cscanf(ReadFunction8 pReadFunction8, void* pContext, const char* pFormat, ...); + EASTDC_API int Fscanf(FILE* pFile, const char* pFormat, ...); + EASTDC_API int Scanf(const char* pFormat, ...); + EASTDC_API int Sscanf(const char* pTextBuffer, const char* pFormat, ...); EASTDC_API int Cscanf(ReadFunction16 pReadFunction16, void* pContext, const char16_t* pFormat, ...); EASTDC_API int Fscanf(FILE* pFile, const char16_t* pFormat, ...); @@ -2685,10 +2685,10 @@ static int TestScanfVariants() EASTDC_API int Sscanf(const char32_t* pTextBuffer, const char32_t* pFormat, ...); - EASTDC_API int Vcscanf(ReadFunction8 pReadFunction8, void* pContext, const char8_t* pFormat, va_list arguments); - EASTDC_API int Vfscanf(FILE* pFile, const char8_t* pFormat, va_list arguments); - EASTDC_API int Vscanf(const char8_t* pFormat, va_list arguments); - EASTDC_API int Vsscanf(const char8_t* pTextBuffer, const char8_t* pFormat, va_list arguments); + EASTDC_API int Vcscanf(ReadFunction8 pReadFunction8, void* pContext, const char* pFormat, va_list arguments); + EASTDC_API int Vfscanf(FILE* pFile, const char* pFormat, va_list arguments); + EASTDC_API int Vscanf(const char* pFormat, va_list arguments); + EASTDC_API int Vsscanf(const char* pTextBuffer, const char* pFormat, va_list arguments); EASTDC_API int Vcscanf(ReadFunction16 pReadFunction16, void* pContext, const char16_t* pFormat, va_list arguments); EASTDC_API int Vfscanf(FILE* pFile, const char16_t* pFormat, va_list arguments); diff --git a/test/source/TestSprintf.cpp b/test/source/TestSprintf.cpp index b935f6b..8f43925 100644 --- a/test/source/TestSprintf.cpp +++ b/test/source/TestSprintf.cpp @@ -16,7 +16,7 @@ #include -static void TestCRTVsnprintf(char8_t* pDestination, size_t n, const char8_t* pFormat, ...) +static void TestCRTVsnprintf(char* pDestination, size_t n, const char* pFormat, ...) { va_list vList; va_start(vList, pFormat); @@ -42,7 +42,7 @@ static void TestCRTVsnprintf(char32_t* pDestination, size_t n, const char32_t* p #if EASTDC_VSNPRINTF8_ENABLED - static void TestCRTVsnprintf8(char8_t* pDestination, size_t n, const char8_t* pFormat, ...) + static void TestCRTVsnprintf8(char* pDestination, size_t n, const char* pFormat, ...) { va_list vList; va_start(vList, pFormat); @@ -90,7 +90,7 @@ static int TestSprintf8(int unused = 0, ...) // int Snprintf(char_t* pDestination, size_t n, const char_t* pFormat, ...); { - char8_t sn18[128]; + char sn18[128]; Snprintf(sn18, 128, "%5s%-4d%03i", "abc", -12, 3); EATEST_VERIFY(!Strcmp(" abc-12 003", sn18)); Snprintf(sn18, 128, "%.2f", 3.1415); @@ -99,7 +99,7 @@ static int TestSprintf8(int unused = 0, ...) // int Vsnprintf(char_t* pDestination, size_t n, const char_t* pFormat, ...); { - char8_t sn18[128]; + char sn18[128]; TestCRTVsnprintf(sn18, 128, "%5s%-5d%04i", "abc", -12, 3); EATEST_VERIFY(!Strcmp(" abc-12 0003", sn18)); TestCRTVsnprintf(sn18, 128, "%.2f", 3.1415); @@ -108,7 +108,7 @@ static int TestSprintf8(int unused = 0, ...) #if EASTDC_VSNPRINTF8_ENABLED { - char8_t sn18[128]; + char sn18[128]; TestCRTVsnprintf8(sn18, 128, "%5s%-5d%04i", "abc", -12, 3); EATEST_VERIFY(!Strcmp(" abc-12 0003", sn18)); TestCRTVsnprintf8(sn18, 128, "%.2f", 3.1415); @@ -130,12 +130,12 @@ static int TestSprintf8(int unused = 0, ...) // template - // int StringVcprintf(String& s, const char8_t* EA_RESTRICT pFormat, va_list arguments) + // int StringVcprintf(String& s, const char* EA_RESTRICT pFormat, va_list arguments) { va_list arguments; va_start(arguments, unused); - eastl::string8 s8; + eastl::string s8; int result = StringVcprintf(s8, "hello", arguments); EATEST_VERIFY((result == 5) && (s8 == "hello")); @@ -146,7 +146,7 @@ static int TestSprintf8(int unused = 0, ...) // template // int StringPrintf(String& s, const typename String::value_type* EA_RESTRICT pFormat, ...) { - eastl::string8 s8; + eastl::string s8; int result = StringPrintf(s8, "%s", "hello"); EATEST_VERIFY((result == 5) && (s8 == "hello")); } @@ -159,14 +159,14 @@ static int TestSprintf8(int unused = 0, ...) { // Test for parsing of PRI constants in format strings - char8_t buffer[128]; + char buffer[128]; Sprintf(buffer, "%" PRIxPTR, (intptr_t) 0xDEADBEEF); EATEST_VERIFY(Strcmp(buffer, "deadbeef") == 0); } // Sprintf { - char8_t buffer[128]; + char buffer[128]; const int kHexValue = 0x12; Sprintf(buffer, "%.4x", kHexValue); @@ -202,7 +202,7 @@ static int TestSprintf8(int unused = 0, ...) { - char8_t buffer[128]; + char buffer[128]; Sprintf(buffer, "decimal negative: \"%d\"\n", -2345); EATEST_VERIFY(Strcmp(buffer, "decimal negative: \"-2345\"\n") == 0); @@ -249,9 +249,9 @@ static int TestSprintf8(int unused = 0, ...) { - char8_t buffer[1024]; - char8_t str1[] = "abc de"; - char8_t str2[] = "abd def ghi jkl mno pqr stu vwz yz."; + char buffer[1024]; + char str1[] = "abc de"; + char str2[] = "abd def ghi jkl mno pqr stu vwz yz."; // The C99 standard specifies that leading zeros only put zeroes in front of numerical types. Spaces for others. Sprintf(buffer, "zero-padded string: \"%010s\"\n", str1); @@ -269,13 +269,13 @@ static int TestSprintf8(int unused = 0, ...) Sprintf(buffer, "limited string: \"%.22s\"\n", str2); EATEST_VERIFY(Strcmp(buffer, "limited string: \"abd def ghi jkl mno pq\"\n") == 0); - Sprintf(buffer, "null string: \"%s\"\n", (char8_t*)NULL); + Sprintf(buffer, "null string: \"%s\"\n", (char*)NULL); EATEST_VERIFY(Strcmp(buffer, "null string: \"(null)\"\n") == 0); - Sprintf(buffer, "%10s\n", (char8_t*)NULL); + Sprintf(buffer, "%10s\n", (char*)NULL); EATEST_VERIFY(Strcmp(buffer, " (null)\n") == 0); - Sprintf(buffer, "%-10s\n", (char8_t*)NULL); + Sprintf(buffer, "%-10s\n", (char*)NULL); EATEST_VERIFY(Strcmp(buffer, "(null) \n") == 0); Sprintf(buffer, "%*s%*s%*s", -1, "one", -20, "two", -30, "three"); @@ -298,20 +298,20 @@ static int TestSprintf8(int unused = 0, ...) { // String tests - // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char8_t, char16_t, char32_t) - // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char8_t, char16_t, char32_t) - // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char8_t, char16_t, char32_t) - // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char8_t, char16_t, char32_t) + // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char, char16_t, char32_t) + // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char, char16_t, char32_t) + // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char, char16_t, char32_t) + // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char, char16_t, char32_t) - char8_t buffer[32]; - char8_t dStr8[2] = { 'd', 0 }; + char buffer[32]; + char dStr8[2] = { 'd', 0 }; char16_t eStr16[2] = { 'e', 0 }; char32_t fStr32[2] = { 'f', 0 }; - Sprintf(buffer, "%hc %c %lc %I8c %I16c %I32c", 'a', 'b', EA_WCHAR('c'), (char8_t)'d', (char16_t)'e', (char32_t)'f'); + Sprintf(buffer, "%hc %c %lc %I8c %I16c %I32c", 'a', 'b', EA_WCHAR('c'), (char)'d', (char16_t)'e', (char32_t)'f'); EATEST_VERIFY(Strcmp(buffer, "a b c d e f") == 0); - Sprintf(buffer, "%hC %C %lC %I8C %I16C %I32C", 'a', EA_WCHAR('b'), EA_WCHAR('c'), (char8_t)'d', (char16_t)'e', (char32_t)'f'); + Sprintf(buffer, "%hC %C %lC %I8C %I16C %I32C", 'a', EA_WCHAR('b'), EA_WCHAR('c'), (char)'d', (char16_t)'e', (char32_t)'f'); EATEST_VERIFY(Strcmp(buffer, "a b c d e f") == 0); Sprintf(buffer, "%hs %s %ls %I8s %I16s %I32s", "a", "b", EA_WCHAR("c"), dStr8, eStr16, fStr32); @@ -323,7 +323,7 @@ static int TestSprintf8(int unused = 0, ...) { // NaN/Inf functionality tests - char8_t buffer[256]; + char buffer[256]; const float kFloat32PositiveInfinity = FloatFromBitRepr(UINT32_C(0x7f800000)); const float kFloat32NegativeInfinity = FloatFromBitRepr(UINT32_C(0xff800000)); @@ -367,7 +367,7 @@ static int TestSprintf8(int unused = 0, ...) Sprintf(buffer, "%e %f %g", kFloat64NegativeNaN, kFloat64NegativeNaN, kFloat64NegativeNaN); EATEST_VERIFY(Strcmp(buffer, "-nan -nan -nan") == 0); - #if !defined(EA_PLATFORM_CAPILANO) + #if !defined(EA_PLATFORM_XBOXONE) // This test should theoretically work on Capilano. But currently it must be disabled or it // will cause the runtime to assert. A bug has been logged with MS so hopefully the issue // will be resolved in the future. We should try to enable the test later if it is resolved. @@ -382,7 +382,7 @@ static int TestSprintf8(int unused = 0, ...) { // Extended functionality tests - char8_t buffer[256]; + char buffer[256]; Sprintf(buffer, "%08x %032b", 0xaaaaaaaa, 0xaaaaaaaa); EATEST_VERIFY(Strcmp(buffer, "aaaaaaaa 10101010101010101010101010101010") == 0); @@ -396,7 +396,7 @@ static int TestSprintf8(int unused = 0, ...) { - char8_t buffer[1024]; + char buffer[1024]; int i; Sprintf(buffer, "e-style >= 1: \"%e\"\n", 12.34); @@ -502,8 +502,8 @@ static int TestSprintf8(int unused = 0, ...) { - char8_t buffer[256]; - const char8_t* pExpected; + char buffer[256]; + const char* pExpected; // VC++ sprintf would fail these tests, as the Standard says to print no more // than 2 unless necessary, yet VC++ sprintf prints 3 digits exponents. @@ -542,28 +542,28 @@ static int TestSprintf8(int unused = 0, ...) { - char8_t buffer[256]; + char buffer[256]; // Verify that snprintf follows the C99 convention of returning the number of characters // required. This is as opposed to the non-standard way that some libraries just return // -1 if the buffer isn't big enough. const int kBuf1Capacity = 20; - char8_t buf1[kBuf1Capacity]; + char buf1[kBuf1Capacity]; int n1 = Snprintf(buf1, kBuf1Capacity, "%30s", "foo"); Sprintf(buffer, "snprintf(\"%%30s\", \"foo\") == %d, \"%.*s\"\n", n1, kBuf1Capacity, buf1); EATEST_VERIFY(Strcmp(buffer, "snprintf(\"%30s\", \"foo\") == 30, \" \"\n") == 0); // VC++ fails this, as it's version of snprintf doesn't use C99 standard snprintf return value conventions. const int kBuf2Capacity = 512; - char8_t buf2[kBuf2Capacity]; + char buf2[kBuf2Capacity]; int n2 = Snprintf(buf2, kBuf2Capacity, "%.1000u", 10); Sprintf(buffer, "snprintf(\"%%.1000u\", 10) == %d\n", n2); EATEST_VERIFY(Strcmp(buffer, "snprintf(\"%.1000u\", 10) == 1000\n") == 0); // VC++ fails this, as it's version of snprintf doesn't use C99 standard snprintf return value conventions. const int kBuf3Capacity = 512; - char8_t buf3[kBuf3Capacity]; - char8_t* pString = new char8_t[100000]; - memset(pString, '_', 100000 * sizeof(char8_t)); + char buf3[kBuf3Capacity]; + char* pString = new char[100000]; + memset(pString, '_', 100000 * sizeof(char)); pString[100000 - 1] = 0; int n3 = Snprintf(buf3, kBuf2Capacity, "%s", pString); Sprintf(buffer, "snprintf(\"%%s\", pString) == %d\n", n3); @@ -581,7 +581,7 @@ static int TestSprintf8(int unused = 0, ...) { - char8_t buffer[16][256]; + char buffer[16][256]; int n = 0, i, j, k, m; @@ -593,8 +593,8 @@ static int TestSprintf8(int unused = 0, ...) { for(m = 0; m < 2; m++) { - char8_t prefix[7]; - char8_t format[128]; + char prefix[7]; + char format[128]; Strcpy(prefix, "%"); if(i == 0) @@ -639,8 +639,8 @@ static int TestSprintf8(int unused = 0, ...) { - char8_t buffer[256]; - const char8_t* pExpected; + char buffer[256]; + const char* pExpected; Sprintf(buffer, "%e", 1234567.8); // VC++ sprintf would fail this, as it uses 3 exponent digits, but the Standard says to print no more than 2 unless necessary. pExpected = "1.234568e+06"; @@ -703,8 +703,8 @@ static int TestSprintf8(int unused = 0, ...) { // Test the ' extension, which cases numbers to be printed with a thousands separator. - char8_t buffer[64]; - const char8_t* pExpected; + char buffer[64]; + const char* pExpected; Sprintf(buffer, "%'u", 123456789); EATEST_VERIFY(Strcmp(buffer, "123,456,789") == 0); @@ -762,7 +762,7 @@ static int TestSprintf8(int unused = 0, ...) { - char8_t buffer[256]; + char buffer[256]; Sprintf(buffer, "%hhu", UCHAR_MAX + 2); EATEST_VERIFY(Strcmp(buffer, "1") == 0); // VC++ fails this, as it doesn't implement the C99 standard %hh modifier. @@ -773,7 +773,7 @@ static int TestSprintf8(int unused = 0, ...) { - char8_t buffer[128]; + char buffer[128]; Sprintf(buffer, "%5.s", "xyz"); EATEST_VERIFY(Strcmp(buffer, " ") == 0); @@ -796,7 +796,7 @@ static int TestSprintf8(int unused = 0, ...) { - char8_t buffer[128]; + char buffer[128]; int precision; //for %g, precision 0 is not valid, if specified 0, it is taken as 1 precision = 0; @@ -831,7 +831,7 @@ static int TestSprintf8(int unused = 0, ...) { // EAC tests - char8_t dest1[1024], dest3[1024]; + char dest1[1024], dest3[1024]; // Test #1 Sprintf(dest1, "Hello. Test."); @@ -850,8 +850,8 @@ static int TestSprintf8(int unused = 0, ...) EATEST_VERIFY(Strcmp(dest1, "Float. -0.010000 10.000000 0.000000\n") == 0); // Test #5 - Sprintf(dest1, "Str/char8_t: %s %c %c", "test", 'b', 0341); - EATEST_VERIFY(Strcmp(dest1, "Str/char8_t: test b \341") == 0); + Sprintf(dest1, "Str/char: %s %c %c", "test", 'b', 0341); + EATEST_VERIFY(Strcmp(dest1, "Str/char: test b \341") == 0); // Test #6 Sprintf(dest1,"Hex: %x %X",3829,-392); @@ -942,38 +942,38 @@ static int TestSprintf8(int unused = 0, ...) const float list1f[]={0.832f,0.00832f,8.32f,0.0f,-0.15f}; - const char8_t* list1[]={"0.832000","0.008320","8.320000","0.000000","-0.150000"}; + const char* list1[]={"0.832000","0.008320","8.320000","0.000000","-0.150000"}; const float list2f[]={0.0000000000123f,0.000000000123f,0.00000000123f,0.0000000123f ,0.000000123f,0.00000123f,0.0000123f,0.000123f,0.00123f,0.0123f,0.123f,1.23f ,12.3f,123.0f,1230.0f,12300.0f,123000.0f,1230000.0f,12300000.0f,123000000.0f,12300000000.0f}; - const char8_t* list2[]={"0.000000","0.000000","0.000000","0.000000" + const char* list2[]={"0.000000","0.000000","0.000000","0.000000" ,"0.000000","0.000001","0.000012","0.000123","0.001230","0.012300","0.123000","1.230000" ,"12.300000","123.000000","1230.000000","12300.000000","123000.000000","1230000.000000", "12300000.000000","123000000.000000","12300000000.000000"}; - const char8_t* list22D[]={"0.00","0.00","0.00","0.00" + const char* list22D[]={"0.00","0.00","0.00","0.00" ,"0.00","0.00","0.00","0.00","0.00","0.01","0.12","1.23" ,"12.30","123.00","1230.00","12300.00","123000.00","1230000.00","12300000.00", "123000000.00","12300000000.00"}; - const char8_t* list23DSL[]={"1.230e-11","1.230e-10","1.230e-09","1.230e-08" + const char* list23DSL[]={"1.230e-11","1.230e-10","1.230e-09","1.230e-08" ,"1.230e-07","1.230e-06","1.230e-05","1.230e-04","1.230e-03","1.230e-02","1.230e-01","1.230e+00" ,"1.230e+01","1.230e+02","1.230e+03","1.230e+04","1.230e+05","1.230e+06","1.230e+07","1.230e+08" ,"1.230e+10"}; - const char8_t* list24DSL[]={"1.230E-11","1.230E-10","1.230E-09","1.230E-08" + const char* list24DSL[]={"1.230E-11","1.230E-10","1.230E-09","1.230E-08" ,"1.230E-07","1.230E-06","1.230E-05","1.230E-04","1.230E-03","1.230E-02","1.230E-01","1.230E+00" ,"1.230E+01","1.230E+02","1.230E+03","1.230E+04","1.230E+05","1.230E+06","1.230E+07","1.230E+08" ,"1.230E+10"}; - const char8_t* list31DSL[]={"1.23e-11","1.23e-10","1.23e-09","1.23e-08" + const char* list31DSL[]={"1.23e-11","1.23e-10","1.23e-09","1.23e-08" ,"1.23e-07","1.23e-06","1.23e-05","0","0.001","0.012","0.123","1.23" ,"12.3","123","1.23e+03","1.23e+04","1.23e+05","1.23e+06","1.23e+07","1.23e+08" ,"1.23e+10"}; - const char8_t* list32DSL[]={"1.23E-11","1.23E-10","1.23E-09","1.23E-08" + const char* list32DSL[]={"1.23E-11","1.23E-10","1.23E-09","1.23E-08" ,"1.23E-07","1.23E-06","1.23E-05","0","0.001","0.012","0.123","1.23" ,"12.3","123","1.23E+03","1.23E+04","1.23E+05","1.23E+06","1.23E+07","1.23E+08" ,"1.23E+10"}; @@ -981,7 +981,7 @@ static int TestSprintf8(int unused = 0, ...) int32_t list1size = sizeof(list1f)/sizeof(list1f[0]); int32_t list2size = sizeof(list2f)/sizeof(list2f[0]); int32_t i, error; - char8_t str[256]; + char str[256]; error = 0; for(i = 0; i < list1size; i++) @@ -1076,13 +1076,13 @@ static int TestSprintf8(int unused = 0, ...) EA::StdC::Snprintf(format, sizeof(format), "%%.%us%%c123", kBufferSize - 1); EATEST_VERIFY(Strcmp(format, "%.2047s%c123") == 0); - auto unique_buffer = eastl::make_unique(kBufferSize); - auto unique_expect = eastl::make_unique(kBufferSize + 16); - auto unique_actual = eastl::make_unique(kBufferSize + 16); + auto unique_buffer = eastl::make_unique(kBufferSize); + auto unique_expect = eastl::make_unique(kBufferSize + 16); + auto unique_actual = eastl::make_unique(kBufferSize + 16); - char8_t* buffer = unique_buffer.get(); - char8_t* expectedOutput = unique_expect.get(); - char8_t* actualOutput = unique_actual.get(); + char* buffer = unique_buffer.get(); + char* expectedOutput = unique_expect.get(); + char* actualOutput = unique_actual.get(); memset(buffer, '?', kBufferSize); buffer[kBufferSize - 1] = 0; @@ -1099,8 +1099,8 @@ static int TestSprintf8(int unused = 0, ...) static const int kSourceSize = 1024 * 5; static const int kOutputSize = kSourceSize + 100; char16_t value[kSourceSize]; - char8_t destination[kOutputSize]; - char8_t comparison[kOutputSize]; + char destination[kOutputSize]; + char comparison[kOutputSize]; for(int i = 0; i < kSourceSize - 1; ++i) { @@ -1120,9 +1120,9 @@ static int TestSprintf8(int unused = 0, ...) /* Copied from rwstdc but not completed. // Compare with Sprintf { - char8_t buffer1[128]; - char8_t buffer2[128]; - char8_t* test = "test %d %5.2f %s \n \t\t\\\\ %X"; + char buffer1[128]; + char buffer2[128]; + char* test = "test %d %5.2f %s \n \t\t\\\\ %X"; Sprintf(buffer1, test, -3923, 0.38293, "test", 4568); Snprintf(buffer2, 128, test, -3923, 0.38293, "test", 4568); @@ -1132,8 +1132,8 @@ static int TestSprintf8(int unused = 0, ...) // Compare with standard sprintf { - char8_t buffer1[128]; - char8_t buffer2[128]; + char buffer1[128]; + char buffer2[128]; char* test = "test %d %5.2f %s \n \t\t\\\\ %X"; sprintf(buffer1, test, -3923, 0.38293, "test", 4568); @@ -1228,7 +1228,7 @@ static int TestSprintf16(int unused = 0, ...) } // template - // int StringVcprintf(String& s, const char8_t* EA_RESTRICT pFormat, va_list arguments) + // int StringVcprintf(String& s, const char* EA_RESTRICT pFormat, va_list arguments) { va_list arguments; va_start(arguments, unused); @@ -1381,21 +1381,21 @@ static int TestSprintf16(int unused = 0, ...) { // String tests - // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char8_t, char16_t, char32_t) - // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char8_t, char16_t, char32_t) - // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char8_t, char16_t, char32_t) - // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char8_t, char16_t, char32_t) + // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char, char16_t, char32_t) + // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char, char16_t, char32_t) + // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char, char16_t, char32_t) + // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char, char16_t, char32_t) char16_t buffer[32]; - char8_t dStr8[2] = { 'd', 0 }; + char dStr8[2] = { 'd', 0 }; char16_t eStr16[2] = { 'e', 0 }; char32_t fStr32[2] = { 'f', 0 }; - #if EASPRINTF_MS_STYLE_S_FORMAT // Microsoft style means that the meanings of S and s are reversed for non-char8_t Sprintf. - Sprintf(buffer, EA_CHAR16("%hc %c %lc %I8c %I16c %I32c"), 'a', EA_WCHAR('b'), EA_WCHAR('c'), (char8_t)'d', (char16_t)'e', (char32_t)'f'); + #if EASPRINTF_MS_STYLE_S_FORMAT // Microsoft style means that the meanings of S and s are reversed for non-char Sprintf. + Sprintf(buffer, EA_CHAR16("%hc %c %lc %I8c %I16c %I32c"), 'a', EA_WCHAR('b'), EA_WCHAR('c'), (char)'d', (char16_t)'e', (char32_t)'f'); EATEST_VERIFY(Strcmp(buffer, EA_CHAR16("a b c d e f")) == 0); - Sprintf(buffer, EA_CHAR16("%hC %C %lC %I8C %I16C %I32C"), 'a', 'b', EA_WCHAR('c'), (char8_t)'d', (char16_t)'e', (char32_t)'f'); + Sprintf(buffer, EA_CHAR16("%hC %C %lC %I8C %I16C %I32C"), 'a', 'b', EA_WCHAR('c'), (char)'d', (char16_t)'e', (char32_t)'f'); EATEST_VERIFY(Strcmp(buffer, EA_CHAR16("a b c d e f")) == 0); Sprintf(buffer, EA_CHAR16("%hs %s %ls %I8s %I16s %I32s"), "a", EA_WCHAR("b"), EA_WCHAR("c"), dStr8, eStr16, fStr32); @@ -1404,10 +1404,10 @@ static int TestSprintf16(int unused = 0, ...) Sprintf(buffer, EA_CHAR16("%hS %S %lS %I8S %I16S %I32S"), "a", "b", EA_WCHAR("c"), dStr8, eStr16, fStr32); EATEST_VERIFY(Strcmp(buffer, EA_CHAR16("a b c d e f")) == 0); #else - Sprintf(buffer, EA_CHAR16("%hc %c %lc %I8c %I16c %I32c"), 'a', 'b', EA_WCHAR('c'), (char8_t)'d', (char16_t)'e', (char32_t)'f'); + Sprintf(buffer, EA_CHAR16("%hc %c %lc %I8c %I16c %I32c"), 'a', 'b', EA_WCHAR('c'), (char)'d', (char16_t)'e', (char32_t)'f'); EATEST_VERIFY(Strcmp(buffer, EA_CHAR16("a b c d e f")) == 0); - Sprintf(buffer, EA_CHAR16("%hC %C %lC %I8C %I16C %I32C"), 'a', EA_WCHAR('b'), EA_WCHAR('c'), (char8_t)'d', (char16_t)'e', (char32_t)'f'); + Sprintf(buffer, EA_CHAR16("%hC %C %lC %I8C %I16C %I32C"), 'a', EA_WCHAR('b'), EA_WCHAR('c'), (char)'d', (char16_t)'e', (char32_t)'f'); EATEST_VERIFY(Strcmp(buffer, EA_CHAR16("a b c d e f)") == 0); Sprintf(buffer, EA_CHAR16("%hs %s %ls %I8s %I16s %I32s"), "a", "b", EA_WCHAR("c"), dStr8, eStr16, fStr32); @@ -1803,7 +1803,7 @@ static int TestSprintf16(int unused = 0, ...) { static const int kSourceSize = 1024 * 5; static const int kOutputSize = kSourceSize + 100; - char8_t value[kSourceSize]; + char value[kSourceSize]; char16_t destination[kOutputSize]; char16_t comparison[kOutputSize]; @@ -1872,7 +1872,7 @@ static int TestSprintf32(int unused = 0, ...) } // template - // int StringVcprintf(String& s, const char8_t* EA_RESTRICT pFormat, va_list arguments) + // int StringVcprintf(String& s, const char* EA_RESTRICT pFormat, va_list arguments) { va_list arguments; va_start(arguments, unused); @@ -2025,21 +2025,21 @@ static int TestSprintf32(int unused = 0, ...) { // String tests - // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char8_t, char16_t, char32_t) - // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char8_t, char16_t, char32_t) - // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char8_t, char16_t, char32_t) - // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char8_t, char16_t, char32_t) + // We accept %hc, %c, %lc, %I8c, %I16c, %I32c (regular, regular, wide, char, char16_t, char32_t) + // We accept %hC, %C, %lC, %I8C, %I16C, %I32C (regular, wide, wide, char, char16_t, char32_t) + // We accept %hs, %s, %ls, %I8s, %I16s, %I32s (regular, regular, wide, char, char16_t, char32_t) + // We accept %hS, %S, %lS, %I8s, %I16s, %I32s (regular, wide, wide, char, char16_t, char32_t) char32_t buffer[32]; - char8_t dStr8[2] = { 'd', 0 }; + char dStr8[2] = { 'd', 0 }; char16_t eStr16[2] = { 'e', 0 }; char32_t fStr32[2] = { 'f', 0 }; - #if EASPRINTF_MS_STYLE_S_FORMAT // Microsoft style means that the meanings of S and s are reversed for non-char8_t Sprintf. - Sprintf(buffer, EA_CHAR32("%hc %c %lc %I8c %I16c %I32c"), 'a', EA_WCHAR('b'), EA_WCHAR('c'), (char8_t)'d', (char16_t)'e', (char32_t)'f'); + #if EASPRINTF_MS_STYLE_S_FORMAT // Microsoft style means that the meanings of S and s are reversed for non-char Sprintf. + Sprintf(buffer, EA_CHAR32("%hc %c %lc %I8c %I16c %I32c"), 'a', EA_WCHAR('b'), EA_WCHAR('c'), (char)'d', (char16_t)'e', (char32_t)'f'); EATEST_VERIFY(Strcmp(buffer, EA_CHAR32("a b c d e f")) == 0); - Sprintf(buffer, EA_CHAR32("%hC %C %lC %I8C %I16C %I32C"), 'a', 'b', EA_WCHAR('c'), (char8_t)'d', (char16_t)'e', (char32_t)'f'); + Sprintf(buffer, EA_CHAR32("%hC %C %lC %I8C %I16C %I32C"), 'a', 'b', EA_WCHAR('c'), (char)'d', (char16_t)'e', (char32_t)'f'); EATEST_VERIFY(Strcmp(buffer, EA_CHAR32("a b c d e f")) == 0); Sprintf(buffer, EA_CHAR32("%hs %s %ls %I8s %I16s %I32s"), "a", EA_WCHAR("b"), EA_WCHAR("c"), dStr8, eStr16, fStr32); @@ -2048,10 +2048,10 @@ static int TestSprintf32(int unused = 0, ...) Sprintf(buffer, EA_CHAR32("%hS %S %lS %I8S %I16S %I32S"), "a", "b", EA_WCHAR("c"), dStr8, eStr16, fStr32); EATEST_VERIFY(Strcmp(buffer, EA_CHAR32("a b c d e f")) == 0); #else - Sprintf(buffer, EA_CHAR32("%hc %c %lc %I8c %I16c %I32c"), 'a', 'b', EA_WCHAR('c'), (char8_t)'d', (char16_t)'e', (char32_t)'f'); + Sprintf(buffer, EA_CHAR32("%hc %c %lc %I8c %I16c %I32c"), 'a', 'b', EA_WCHAR('c'), (char)'d', (char16_t)'e', (char32_t)'f'); EATEST_VERIFY(Strcmp(buffer, EA_CHAR32("a b c d e f")) == 0); - Sprintf(buffer, EA_CHAR32("%hC %C %lC %I8C %I16C %I32C"), 'a', EA_WCHAR('b'), EA_WCHAR('c'), (char8_t)'d', (char16_t)'e', (char32_t)'f'); + Sprintf(buffer, EA_CHAR32("%hC %C %lC %I8C %I16C %I32C"), 'a', EA_WCHAR('b'), EA_WCHAR('c'), (char)'d', (char16_t)'e', (char32_t)'f'); EATEST_VERIFY(Strcmp(buffer, EA_CHAR32("a b c d e f)") == 0); Sprintf(buffer, EA_CHAR32("%hs %s %ls %I8s %I16s %I32s"), "a", "b", EA_WCHAR("c"), dStr8, eStr16, fStr32); @@ -2446,7 +2446,7 @@ static int TestSprintf32(int unused = 0, ...) { static const int kSourceSize = 1024 * 5; static const int kOutputSize = kSourceSize + 100; - char8_t value[kSourceSize]; + char value[kSourceSize]; char32_t destination[kOutputSize]; char32_t comparison[kOutputSize]; @@ -2480,11 +2480,11 @@ static int TestDrintf8() Dprintf("Begin Dprintf (debug output printf) testing...\n"); - // EASTDC_API int Vdprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments); - // EASTDC_API int Dprintf(const char8_t* EA_RESTRICT pFormat, ...); + // EASTDC_API int Vdprintf(const char* EA_RESTRICT pFormat, va_list arguments); + // EASTDC_API int Dprintf(const char* EA_RESTRICT pFormat, ...); eastl::string8 sBuffer; for(eastl_size_t i = 0; i < 1024; i++) // This size should be > than the size of the buffer(s) used in PlatformLogWriter8, though those buffer sizes aren't publicly exposed. - sBuffer.push_back('a' + (char8_t)(i % 26)); + sBuffer.push_back('a' + (char)(i % 26)); EA::UnitTest::Rand rand((uint32_t)EA::StdC::GetTime()); @@ -2497,10 +2497,10 @@ static int TestDrintf8() } #if EASTDC_PRINTF_DEBUG_ENABLED - // EASTDC_API int Fprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFormat, ...); - // EASTDC_API int Printf(const char8_t* EA_RESTRICT pFormat, ...); - // EASTDC_API int Vfprintf(FILE* EA_RESTRICT pFile, const char8_t* EA_RESTRICT pFormat, va_list arguments); - // EASTDC_API int Vprintf(const char8_t* EA_RESTRICT pFormat, va_list arguments); + // EASTDC_API int Fprintf(FILE* EA_RESTRICT pFile, const char* EA_RESTRICT pFormat, ...); + // EASTDC_API int Printf(const char* EA_RESTRICT pFormat, ...); + // EASTDC_API int Vfprintf(FILE* EA_RESTRICT pFile, const char* EA_RESTRICT pFormat, va_list arguments); + // EASTDC_API int Vprintf(const char* EA_RESTRICT pFormat, va_list arguments); result = Printf("%s", "Printf test (EASTDC_PRINTF_DEBUG_ENABLED).\n"); EATEST_VERIFY(result > 0); @@ -2522,7 +2522,7 @@ static int TestOsprintf8() int nErrorCount = 0; { - char8_t buffer[32]; + char buffer[32]; int result; memset(buffer, 0, sizeof(buffer)); @@ -2710,47 +2710,6 @@ static int TestOsprintf32() } -/////////////////////////////////////////////////////////////////////////////// -// TestDeprecated -/////////////////////////////////////////////////////////////////////////////// - -static int StringWriterOld8(const char8_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext8) -{ - eastl::string8* pString8 = static_cast(pContext8); - pString8->append(pData, (eastl_size_t)nCount); - return (int)nCount; -} - -static int StringWriterOld16(const char16_t* EA_RESTRICT pData, size_t nCount, void* EA_RESTRICT pContext16) -{ - eastl::string16* pString16 = static_cast(pContext16); - pString16->append(pData, (eastl_size_t)nCount); - return (int)nCount; -} - -static int TestDeprecated() -{ - using namespace EA::StdC; - - int nErrorCount = 0; - - { - eastl::string8 s8; - eastl::string16 s16; - int result; - - result = Cprintf(StringWriterOld8, &s8, "Hello world"); - EATEST_VERIFY(result == (int)Strlen("Hello world")); - EATEST_VERIFY(s8 == "Hello world"); - - result = Cprintf(StringWriterOld16, &s16, EA_CHAR16("Hello world")); - EATEST_VERIFY(result == (int)Strlen(EA_CHAR16("Hello world"))); - EATEST_VERIFY(s16 == EA_CHAR16("Hello world")); - } - - return nErrorCount; -} - /////////////////////////////////////////////////////////////////////////////// // TestSprintf @@ -2775,9 +2734,6 @@ int TestSprintf() nErrorCount += TestOsprintf16(); nErrorCount += TestOsprintf32(); - // Test deprecated functionality - nErrorCount += TestDeprecated(); - return nErrorCount; } diff --git a/test/source/TestString.cpp b/test/source/TestString.cpp index c1d5b4c..2f4fcde 100644 --- a/test/source/TestString.cpp +++ b/test/source/TestString.cpp @@ -51,10 +51,10 @@ struct CharTraits {}; template <> -struct CharTraits +struct CharTraits { - static char8_t fill_value() { return 0x33; } - static void assign(char8_t* buffer, size_t size, char8_t value) { EA::StdC::Memset8(buffer, value, size); } + static char fill_value() { return 0x33; } + static void assign(char* buffer, size_t size, char value) { EA::StdC::Memset8(buffer, value, size); } typedef char16_t char1_t; typedef char32_t char2_t; }; @@ -64,7 +64,7 @@ struct CharTraits { static char16_t fill_value() { return 0x3344; } static void assign(char16_t* buffer, size_t size, char16_t value) { EA::StdC::Memset16(buffer, value, size); } - typedef char8_t char1_t; + typedef char char1_t; typedef char32_t char2_t; }; @@ -73,7 +73,7 @@ struct CharTraits { static char32_t fill_value() { return 0x33445566; } static void assign(char32_t* buffer, size_t size, char32_t value) { EA::StdC::Memset32(buffer, value, size); } - typedef char8_t char1_t; + typedef char char1_t; typedef char16_t char2_t; }; @@ -368,19 +368,19 @@ static int TestStringCore() size_t sizeResult; //{ // Trigger crash intentionally. - // EA::StdC::AtofEnglish((char8_t*)NULL); + // EA::StdC::AtofEnglish((char*)NULL); //} { // Test user report of inconsistency between FtoaEnglish and Snprintf. - const char8_t* stringValue = "1.2345"; + const char* stringValue = "1.2345"; float floatValue = (float)EA::StdC::AtofEnglish(stringValue); // floatValue = 1.2345000505447387 in FPU register. - char8_t tmp1[64]; + char tmp1[64]; FtoaEnglish(floatValue, tmp1, sizeof(tmp1), 16, false); // tmp1 = "1.23450005" - char8_t tmp2[64]; + char tmp2[64]; Snprintf(tmp2, sizeof(tmp2), "%.16f", floatValue); // tmp1 = "1.2345000505447388" @@ -388,12 +388,12 @@ static int TestStringCore() } - // char8_t* Strcat(char8_t* pDestination, const char8_t* pSource); + // char* Strcat(char* pDestination, const char* pSource); // char16_t* Strcat(char16_t* pDestination, const char16_t* pSource); // char32_t* Strcat(char32_t* pDestination, const char32_t* pSource); { - char8_t s_to[] = "hello\x0 "; - const char8_t* s_from = " world"; + char s_to[] = "hello\x0 "; + const char* s_from = " world"; EATEST_VERIFY(Strcat(s_to, s_from) == s_to); EATEST_VERIFY(Strcmp(s_to, "hello world") == 0); @@ -414,16 +414,16 @@ static int TestStringCore() } - // char8_t* Strncat(char8_t* pDestination, const char8_t* pSource, size_t n); + // char* Strncat(char* pDestination, const char* pSource, size_t n); // char16_t* Strncat(char16_t* pDestination, const char16_t* pSource, size_t n); // char32_t* Strncat(char32_t* pDestination, const char32_t* pSource, size_t n); { - char8_t s_to[] = "0123\x0......"; - const char8_t* s_from = "456789"; + char s_to[] = "0123\x0......"; + const char* s_from = "456789"; EATEST_VERIFY(Strncat(s_to, s_from, 5) == s_to); EATEST_VERIFY(Strcmp(s_to, "012345678") == 0); - EATEST_VERIFY(s_to[9] == char8_t(0)); + EATEST_VERIFY(s_to[9] == char(0)); } { char16_t s_to[24]; Strlcpy(s_to, EA_CHAR16("0123\x0......"), EAArrayCount(s_to)); // Can't do char16_t variable[64] = EA_CHAR16(...) because some compilers don't support 16 bit string literals. @@ -443,7 +443,7 @@ static int TestStringCore() } - // char8_t* StringnCat(char8_t* pDestination, const char8_t* pSource, size_t n); + // char* StringnCat(char* pDestination, const char* pSource, size_t n); // char16_t* StringnCat(char16_t* pDestination, const char16_t* pSource, size_t n); // char32_t* StringnCat(char32_t* pDestination, const char32_t* pSource, size_t n); // @@ -452,13 +452,13 @@ static int TestStringCore() // we verify that their behaviour is the same as the existing rwstdc package, // including any broken behaviour. { - char8_t s_to[] = "0123\x0......"; - const char8_t* s_from = "456789"; + char s_to[] = "0123\x0......"; + const char* s_from = "456789"; EATEST_VERIFY(StringnCat(s_to, s_from, 5) == s_to); //EATEST_VERIFY(Strcmp(s_to, "012345678..") == 0); Disabled while we try to clarify what the expected behaviour is. - Memset8(s_to, (char8_t)'.', Strlen(s_to)); + Memset8(s_to, (char)'.', Strlen(s_to)); EATEST_VERIFY(StringnCat(s_to, s_from, 0) == s_to); EATEST_VERIFY(s_to[0] == '.'); } @@ -486,12 +486,12 @@ static int TestStringCore() } - // size_t Strlcat(char8_t* pDestination, const char8_t* pSource, size_t nDestCapacity); + // size_t Strlcat(char* pDestination, const char* pSource, size_t nDestCapacity); // size_t Strlcat(char16_t* pDestination, const char16_t* pSource, size_t nDestCapacity); // size_t Strlcat(char32_t* pDestination, const char32_t* pSource, size_t nDestCapacity); { - char8_t s_to[8] = "0123\x0.."; - const char8_t* s_from = "456789"; + char s_to[8] = "0123\x0.."; + const char* s_from = "456789"; sizeResult = Strlcat(s_to, s_from, EAArrayCount(s_to)); EATEST_VERIFY(sizeResult == Strlen("0123") + Strlen("456789")); @@ -516,8 +516,8 @@ static int TestStringCore() { - char8_t s_to[] = "01\x0........"; - const char8_t* s_from = "23456"; + char s_to[] = "01\x0........"; + const char* s_from = "23456"; sizeResult = Strlcat(s_to, s_from, EAArrayCount(s_to)); EATEST_VERIFY(sizeResult == Strlen("0123456")); @@ -559,12 +559,12 @@ static int TestStringCore() } - /// char8_t* Strcpy(char8_t* pDestination, const char8_t* pSource); + /// char* Strcpy(char* pDestination, const char* pSource); /// char16_t* Strcpy(char16_t* pDestination, const char16_t* pSource); /// char32_t* Strcpy(char32_t* pDestination, const char32_t* pSource); { - char8_t s_to[] = "0123456789"; - const char8_t* s_from = "1234567890"; + char s_to[] = "0123456789"; + const char* s_from = "1234567890"; EATEST_VERIFY(Strcpy(s_to, s_from) == s_to); EATEST_VERIFY(Strcmp(s_to, "1234567890") == 0); @@ -585,21 +585,21 @@ static int TestStringCore() } - // char8_t* Strncpy(char8_t* pDestination, const char8_t* pSource, size_t n); + // char* Strncpy(char* pDestination, const char* pSource, size_t n); // char16_t* Strncpy(char16_t* pDestination, const char16_t* pSource, size_t n); // char32_t* Strncpy(char32_t* pDestination, const char32_t* pSource, size_t n); { - char8_t s_to[] = "..........................."; - const char8_t* s_from = "l;kajjsdf;q4w3rrpoiu113<>)("; + char s_to[] = "..........................."; + const char* s_from = "l;kajjsdf;q4w3rrpoiu113<>)("; EATEST_VERIFY(Strcpy(s_to, s_from) == s_to); - EATEST_VERIFY(Memcmp(s_to, s_from, Strlen(s_from) * sizeof(char8_t)) == 0); + EATEST_VERIFY(Memcmp(s_to, s_from, Strlen(s_from) * sizeof(char)) == 0); - Memset8(s_to, (char8_t)'.', Strlen(s_to)); + Memset8(s_to, (char)'.', Strlen(s_to)); EATEST_VERIFY(Strncpy(s_to, s_from+14, 5) == s_to); - EATEST_VERIFY(Memcmp(s_to, s_from+14, 5 * sizeof(char8_t)) == 0); - EATEST_VERIFY(s_to[5] == (char8_t)'.' ); + EATEST_VERIFY(Memcmp(s_to, s_from+14, 5 * sizeof(char)) == 0); + EATEST_VERIFY(s_to[5] == (char)'.' ); } { char16_t s_to[32]; Strlcpy(s_to, EA_CHAR16("..........................."), EAArrayCount(s_to)); // Can't do char16_t variable[64] = EA_CHAR16(...) because some compilers don't support 16 bit string literals. @@ -629,19 +629,19 @@ static int TestStringCore() } - // char8_t* StringnCopy(char8_t* pDestination, const char8_t* pSource, size_t n); + // char* StringnCopy(char* pDestination, const char* pSource, size_t n); // char16_t* StringnCopy(char16_t* pDestination, const char16_t* pSource, size_t n); // char32_t* StringnCopy(char32_t* pDestination, const char32_t* pSource, size_t n); { - char8_t s_to[] = "..........................."; - const char8_t* s_from = "l;kajjsdf;q4w3rrpoiu113<>)("; + char s_to[] = "..........................."; + const char* s_from = "l;kajjsdf;q4w3rrpoiu113<>)("; EATEST_VERIFY(StringnCopy(s_to, s_from+14, 5) == s_to); - EATEST_VERIFY(Memcmp(s_to, s_from+14, 5 * sizeof(char8_t)) == 0); - EATEST_VERIFY(s_to[5] == (char8_t)'.' ); + EATEST_VERIFY(Memcmp(s_to, s_from+14, 5 * sizeof(char)) == 0); + EATEST_VERIFY(s_to[5] == (char)'.' ); // Test copying nothing. - Memset8(s_to, (char8_t)'.', Strlen(s_to)); + Memset8(s_to, (char)'.', Strlen(s_to)); EATEST_VERIFY(StringnCopy(s_to, s_from+14, 0) == s_to); EATEST_VERIFY(s_to[0] == '.'); } @@ -651,7 +651,7 @@ static int TestStringCore() EATEST_VERIFY(StringnCopy(s_to, s_from+14, 5) == s_to); EATEST_VERIFY(Memcmp(s_to, s_from+14, 5 * sizeof(char16_t)) == 0); - EATEST_VERIFY(s_to[5] == (char8_t)'.' ); + EATEST_VERIFY(s_to[5] == (char)'.' ); // Test copying nothing. Memset16(s_to, (char16_t)'.', Strlen(s_to)); @@ -664,7 +664,7 @@ static int TestStringCore() EATEST_VERIFY(StringnCopy(s_to, s_from+14, 5) == s_to); EATEST_VERIFY(Memcmp(s_to, s_from+14, 5 * sizeof(char32_t)) == 0); - EATEST_VERIFY(s_to[5] == (char8_t)'.' ); + EATEST_VERIFY(s_to[5] == (char)'.' ); // Test copying nothing. Memset32(s_to, (char32_t)'.', Strlen(s_to)); @@ -672,13 +672,13 @@ static int TestStringCore() EATEST_VERIFY(s_to[0] == '.'); } - // size_t Strlcpy(char8_t* pDestination, const char8_t* pSource, size_t nDestCapacity); + // size_t Strlcpy(char* pDestination, const char* pSource, size_t nDestCapacity); // size_t Strlcpy(char16_t* pDestination, const char16_t* pSource, size_t nDestCapacity); // size_t Strlcpy(char32_t* pDestination, const char32_t* pSource, size_t nDestCapacity); - // int Strlcpy(char8_t* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength = (size_t)~0); - // int Strlcpy(char16_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength = (size_t)~0); - // int Strlcpy(char8_t* pDestination, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength = (size_t)~0); - // int Strlcpy(char32_t* pDestination, const char8_t* pSource, size_t nDestCapacity, size_t nSourceLength = (size_t)~0); + // int Strlcpy(char* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength = (size_t)~0); + // int Strlcpy(char16_t* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength = (size_t)~0); + // int Strlcpy(char* pDestination, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength = (size_t)~0); + // int Strlcpy(char32_t* pDestination, const char* pSource, size_t nDestCapacity, size_t nSourceLength = (size_t)~0); // int Strlcpy(char16_t* pDestination, const char32_t* pSource, size_t nDestCapacity, size_t nSourceLength = (size_t)~0); // int Strlcpy(char32_t* pDestination, const char16_t* pSource, size_t nDestCapacity, size_t nSourceLength = (size_t)~0); { @@ -688,7 +688,7 @@ static int TestStringCore() nErrorCount += StrlcpyTest(""); nErrorCount += StrlcpyTest("\x43\x3A\x5C\x45\x6C\x65\x63\x74\x72\x6F\x6E\x69\x63\x20\x41\x72\x74\x73\x5C\xE3\x82\xB6\xEF\xBD\xA5\xE3\x82\xB7\xE3\x83\xA0\xE3\x82\xBA\xEF\xBC\x93", 25); - const char8_t* kInvalidUTF8StringArray[] = { + const char* kInvalidUTF8StringArray[] = { "\xc2", // 1 byte of a 2 byte sequence "\xc2\x20", // 1 byte of a 2 byte sequence "\xe0", // 1 byte of a 3 byte sequence @@ -709,7 +709,7 @@ static int TestStringCore() } } - /// size_t Strlen(const char8_t* pString); + /// size_t Strlen(const char* pString); /// size_t Strlen(const char16_t* pString); /// size_t Strlen(const char32_t* pString); { @@ -729,7 +729,7 @@ static int TestStringCore() stopwatch.Start(); for(size_t j = 0; j < kBufferSize; ++j) { - size_t n = Strlen((char8_t*)buffer + j); + size_t n = Strlen((char*)buffer + j); EATEST_VERIFY(n == ((kBufferSize - 1) - j)); //if(n != ((kBufferSize - 1) - j)) @@ -793,7 +793,7 @@ static int TestStringCore() - /// size_t StrlenUTF8Decoded(const char8_t* pString); + /// size_t StrlenUTF8Decoded(const char* pString); /// size_t StrlenUTF8Encoded(const char16_t* pString); /// size_t StrlenUTF8Encoded(const char32_t* pString); { @@ -837,11 +837,11 @@ static int TestStringCore() } - /// char8_t* Strend(const char8_t* pString); + /// char* Strend(const char* pString); /// char16_t* Strend(const char16_t* pString); /// char32_t* Strend(const char32_t* pString); { - const char8_t* pString = "0123456789"; + const char* pString = "0123456789"; EATEST_VERIFY(Strend(pString) == (pString + Strlen(pString))); } { @@ -854,13 +854,13 @@ static int TestStringCore() } - // size_t Strxfrm(char8_t* pDest, const char8_t* pSource, size_t n); + // size_t Strxfrm(char* pDest, const char* pSource, size_t n); // size_t Strxfrm(char16_t* pDest, const char16_t* pSource, size_t n); // size_t Strxfrm(char32_t* pDest, const char32_t* pSource, size_t n); { // To do: Make a better test. - char8_t s_to[] = "..........................."; - const char8_t* s_from = "l;kajjsdf;q4w3rrpoiu113<>)("; + char s_to[] = "..........................."; + const char* s_from = "l;kajjsdf;q4w3rrpoiu113<>)("; const size_t n = Strxfrm(s_to, s_from, Strlen(s_from) + 1); EATEST_VERIFY(Strcmp(s_to, s_from) == 0); @@ -886,14 +886,14 @@ static int TestStringCore() } - // char8_t* Strdup(const char8_t* pString); + // char* Strdup(const char* pString); // char16_t* Strdup(const char16_t* pString); // char32_t* Strdup(const char32_t* pString); - // void Strdel(char8_t* pString); + // void Strdel(char* pString); // void Strdel(char16_t* pString); // void Strdel(char32_t* pString); { - typedef char8_t test_type; + typedef char test_type; test_type s_from[] = "..........................."; test_type* s_new = NULL; @@ -924,11 +924,11 @@ static int TestStringCore() } - // char8_t* Strupr(char8_t* pString); + // char* Strupr(char* pString); // char16_t* Strupr(char16_t* pString); // char32_t* Strupr(char32_t* pString); { - char8_t s8[] = "hello world"; + char s8[] = "hello world"; EATEST_VERIFY(Strupr(s8) == s8); EATEST_VERIFY(Memcmp(s8, "HELLO WORLD", EAArrayCount(s8)) == 0); @@ -947,11 +947,11 @@ static int TestStringCore() } - // char8_t* Strlwr(char8_t* pString); + // char* Strlwr(char* pString); // char16_t* Strlwr(char16_t* pString); // char32_t* Strlwr(char32_t* pString); { - char8_t s8[] = "HELLO WORLD"; + char s8[] = "HELLO WORLD"; EATEST_VERIFY(Strlwr(s8) == s8); EATEST_VERIFY(Memcmp(s8, "hello world", EAArrayCount(s8)) == 0); @@ -970,11 +970,11 @@ static int TestStringCore() } - // char8_t* Strchr(const char8_t* pString, int c); + // char* Strchr(const char* pString, int c); // char16_t* Strchr(const char16_t* pString, char16_t c); // char32_t* Strchr(const char32_t* pString, char32_t c); { - char8_t s8[] = "012a456789abc2ef"; + char s8[] = "012a456789abc2ef"; EATEST_VERIFY(Strrchr(s8, 'a') == &s8[0xa]); EATEST_VERIFY(Strrchr(s8, '2') == &s8[0xd]); @@ -999,11 +999,11 @@ static int TestStringCore() } - // size_t Strcspn(const char8_t* pString1, const char8_t* pString2); + // size_t Strcspn(const char* pString1, const char* pString2); // size_t Strcspn(const char16_t* pString1, const char16_t* pString2); // size_t Strcspn(const char32_t* pString1, const char32_t* pString2); { - char8_t s8[] = "0123456789abcdef"; + char s8[] = "0123456789abcdef"; EATEST_VERIFY(Strcspn(s8, "@fa") == 0xa); EATEST_VERIFY(Strcspn(s8, "5.a,f") == 0x5); @@ -1028,11 +1028,11 @@ static int TestStringCore() } - // char8_t* Strpbrk(const char8_t* pString1, const char8_t* pString2); + // char* Strpbrk(const char* pString1, const char* pString2); // char16_t* Strpbrk(const char16_t* pString1, const char16_t* pString2); // char32_t* Strpbrk(const char32_t* pString1, const char32_t* pString2); { - char8_t s8[] = "0123456789abcdef"; + char s8[] = "0123456789abcdef"; EATEST_VERIFY(Strpbrk(s8, "@fa") == &s8[0xa]); EATEST_VERIFY(Strpbrk(s8, "5.a,f") == &s8[0x5]); @@ -1057,11 +1057,11 @@ static int TestStringCore() } - // char8_t* Strrchr(const char8_t* pString, int c); + // char* Strrchr(const char* pString, int c); // char16_t* Strrchr(const char16_t* pString, char16_t c); // char32_t* Strrchr(const char32_t* pString, char32_t c); { - char8_t s8[] = "0123456789abcdef"; + char s8[] = "0123456789abcdef"; EATEST_VERIFY(Strchr(s8, 'z') == NULL); EATEST_VERIFY(Strchr(s8, 'a') == &s8[0xa]); @@ -1086,7 +1086,7 @@ static int TestStringCore() } { - char8_t s8[] = "0123456789abcdef"; + char s8[] = "0123456789abcdef"; EATEST_VERIFY(Strnchr(s8, 'z', EAArrayCount(s8)) == NULL); EATEST_VERIFY(Strnchr(s8, 'a', EAArrayCount(s8)) == &s8[0xa]); @@ -1179,11 +1179,11 @@ static int TestStringCore() EATEST_VERIFY(Strnchr(s32, '\0', EA::StdC::Strlen(s32)+1) == &s32[0x10]); //This is the null terminator } - // size_t Strspn(const char8_t* pString, const char8_t* pSubString); + // size_t Strspn(const char* pString, const char* pSubString); // size_t Strspn(const char16_t* pString, const char16_t* pSubString); // size_t Strspn(const char32_t* pString, const char32_t* pSubString); { - char8_t s8[] = "0123456789abcdef"; + char s8[] = "0123456789abcdef"; EATEST_VERIFY(Strspn(s8, "2103") == 4); EATEST_VERIFY(Strspn(s8+10, "badc") == 4); @@ -1205,11 +1205,11 @@ static int TestStringCore() } - // char8_t* Strstr(const char8_t* pString, const char8_t* pSubString); + // char* Strstr(const char* pString, const char* pSubString); // char16_t* Strstr(const char16_t* pString, const char16_t* pSubString); // char32_t* Strstr(const char32_t* pString, const char32_t* pSubString); { - char8_t s8[] = "012abcdf89abcdef"; + char s8[] = "012abcdf89abcdef"; EATEST_VERIFY(Strstr(s8, "") == &s8[0]); EATEST_VERIFY(Strstr(s8, "012") == &s8[0]); @@ -1237,11 +1237,11 @@ static int TestStringCore() } - // char8_t* Stristr(const char8_t* pString, const char8_t* pSubString); + // char* Stristr(const char* pString, const char* pSubString); // char16_t* Stristr(const char16_t* pString, const char16_t* pSubString); // char32_t* Stristr(const char32_t* pString, const char32_t* pSubString); { - char8_t s8[] = "012aBcdf89aBcDEf"; + char s8[] = "012aBcdf89aBcDEf"; EATEST_VERIFY(Stristr(s8, "012") == &s8[0]); EATEST_VERIFY(Stristr(s8, "abcde") == &s8[10]); @@ -1269,7 +1269,7 @@ static int TestStringCore() } - // char8_t* Strrstr(const char8_t* pString, const char8_t* pSubString); + // char* Strrstr(const char* pString, const char* pSubString); // char16_t* Strrstr(const char16_t* pString, const char16_t* pSubString); // char32_t* Strrstr(const char32_t* pString, const char32_t* pSubString); { @@ -1280,7 +1280,7 @@ static int TestStringCore() } - // char8_t* Strirstr(const char8_t* pString, const char8_t* pSubString); + // char* Strirstr(const char* pString, const char* pSubString); // char16_t* Strirstr(const char16_t* pString, const char16_t* pSubString); // char32_t* Strirstr(const char32_t* pString, const char32_t* pSubString); { @@ -1291,17 +1291,17 @@ static int TestStringCore() } - // char8_t* Strtok(char8_t* pString, const char8_t* pDelimiters, char8_t** pContext); + // char* Strtok(char* pString, const char* pDelimiters, char** pContext); // char16_t* Strtok(char16_t* pString, const char16_t* pDelimiters, char16_t** pContext); // char32_t* Strtok(char32_t* pString, const char32_t* pDelimiters, char32_t** pContext); { - char8_t s8[] = ",.:1:2.3,4"; - char8_t* s8ctx = s8; + char s8[] = ",.:1:2.3,4"; + char* s8ctx = s8; EATEST_VERIFY(Strtok(s8, ",.:", &s8ctx) == &s8[3]); - char8_t p[] = "-abc-=-def"; - char8_t* p1; - char8_t* r; + char p[] = "-abc-=-def"; + char* p1; + char* r; r = Strtok(p, "-", &p1); // r = "abc", p1 = "=-def", p = "abc\0=-def" EATEST_VERIFY(r != NULL); @@ -1325,28 +1325,28 @@ static int TestStringCore() { // Test bug report by user. - char8_t pStr[] = { 'a', '=', 'b', ';', 0 }; - char8_t* pContext = NULL; - char8_t* pToken; + char pStr[] = { 'a', '=', 'b', ';', 0 }; + char* pContext = NULL; + char* pToken; while((pToken = Strtok(pContext ? NULL : pStr, ";", &pContext)) != NULL) { EATEST_VERIFY(pToken != NULL); } // This was looping infinitely. } - // const char8_t* Strtok2(const char8_t* pString, const char8_t* pDelimiters, size_t* pResultLength, bool bFirst); + // const char* Strtok2(const char* pString, const char* pDelimiters, size_t* pResultLength, bool bFirst); // const char16_t* Strtok2(const char16_t* pString, const char16_t* pDelimiters, size_t* pResultLength, bool bFirst); // const char32_t* Strtok2(const char32_t* pString, const char32_t* pDelimiters, size_t* pResultLength, bool bFirst); { - const char8_t* teststr = " Hello /// This/is++a test"; - const char8_t* teststr2 = " /// "; - const char8_t* teststr3 = " /// Hello "; - const char8_t* delim = "/ %"; - const char8_t* token1 = "Hello"; - const char8_t* token2 = "This"; - const char8_t* token3 = "is++a"; - const char8_t* token4 = "test"; - const char8_t* pCurrent; + const char* teststr = " Hello /// This/is++a test"; + const char* teststr2 = " /// "; + const char* teststr3 = " /// Hello "; + const char* delim = "/ %"; + const char* token1 = "Hello"; + const char* token2 = "This"; + const char* token3 = "is++a"; + const char* token4 = "test"; + const char* pCurrent; size_t n; // Test the first string @@ -1471,11 +1471,11 @@ static int TestStringCore() } - // char8_t* Strset(char8_t* pString, int c); + // char* Strset(char* pString, int c); // char16_t* Strset(char16_t* pString, char16_t c); // char32_t* Strset(char32_t* pString, char32_t c); { - char8_t s8[] = ",.:1:2.3,4"; + char s8[] = ",.:1:2.3,4"; EATEST_VERIFY(Strset(s8, '^') == s8); EATEST_VERIFY(Memcmp(s8, "^^^^^^^^^^", Strlen(s8)) == 0); @@ -1494,12 +1494,12 @@ static int TestStringCore() } - // char8_t* Strnset(char8_t* pString, int c, size_t n); + // char* Strnset(char* pString, int c, size_t n); // char16_t* Strnset(char16_t* pString, char16_t c, size_t n); // char32_t* Strnset(char32_t* pString, char32_t c, size_t n); { // To do: Make a real test. For now we merely verify that we can call the function. - char8_t buffer8[32] = {}; + char buffer8[32] = {}; Strnset(buffer8, 'a', 4); char16_t buffer16[32] = {}; @@ -1510,12 +1510,12 @@ static int TestStringCore() } - // char8_t* Strrev(char8_t* pString); + // char* Strrev(char* pString); // char16_t* Strrev(char16_t* pString); // char32_t* Strrev(char32_t* pString); { - char8_t s8[32]; - char8_t sEmpty[1] = { 0 }; + char s8[32]; + char sEmpty[1] = { 0 }; EATEST_VERIFY(Strlen(Strrev(sEmpty)) == 0); @@ -1569,13 +1569,13 @@ static int TestStringCore() } - // int Strcmp(const char8_t* pString1, const char8_t* pString2); + // int Strcmp(const char* pString1, const char* pString2); // int Strcmp(const char16_t* pString1, const char16_t* pString2); // int Strcmp(const char32_t* pString1, const char32_t* pString2); { - char8_t buffer1[] = "01234567a"; - char8_t buffer2[] = "01234567b"; - char8_t buffer3[] = "01234567c"; + char buffer1[] = "01234567a"; + char buffer2[] = "01234567b"; + char buffer3[] = "01234567c"; EATEST_VERIFY(Strcmp(buffer1, buffer1) == 0); EATEST_VERIFY(Strcmp(buffer2, buffer1) > 0); @@ -1607,10 +1607,10 @@ static int TestStringCore() } { - // Extended Strcmp char8_t testing for our optimized version. + // Extended Strcmp char testing for our optimized version. // To do: Use a page-protected heap to test that Strcmp isn't reading beyond a page's boundaries. - eastl::string8 s1; - eastl::string8 s2; + eastl::string s1; + eastl::string s2; EA::UnitTest::Rand rand(1234); for(int i = 0; i < 20; i++) @@ -1628,7 +1628,7 @@ static int TestStringCore() for(eastl_size_t j = 0; j < s1Length; j++) { - s1[j] = (char8_t)rand.RandRange(CHAR_MIN, CHAR_MAX + 1); + s1[j] = (char)rand.RandRange(CHAR_MIN, CHAR_MAX + 1); if(s1[j] == 0) // We can't have a 0 char, as that's the C string terminator char. s1[j] = 'x'; @@ -1701,13 +1701,13 @@ static int TestStringCore() } - // int Strncmp(const char8_t* pString1, const char8_t* pString2, size_t n); + // int Strncmp(const char* pString1, const char* pString2, size_t n); // int Strncmp(const char16_t* pString1, const char16_t* pString2, size_t n); // int Strncmp(const char32_t* pString1, const char32_t* pString2, size_t n); { - char8_t buffer1[] = "01234567abc"; - char8_t buffer2[] = "01234567bbc"; - char8_t buffer3[] = "01234567cbc"; + char buffer1[] = "01234567abc"; + char buffer2[] = "01234567bbc"; + char buffer3[] = "01234567cbc"; EATEST_VERIFY(Strncmp(buffer1, buffer1, 12) == 0); EATEST_VERIFY(Strncmp(buffer2, buffer1, 12) > 0); @@ -1739,13 +1739,13 @@ static int TestStringCore() } - // int Stricmp(const char8_t* pString1, const char8_t* pString2); + // int Stricmp(const char* pString1, const char* pString2); // int Stricmp(const char16_t* pString1, const char16_t* pString2); // int Stricmp(const char32_t* pString1, const char32_t* pString2); { - char8_t buffer1[] = "01asdf67A"; - char8_t buffer2[] = "01aSDf67b"; - char8_t buffer3[] = "01AsdF67C"; + char buffer1[] = "01asdf67A"; + char buffer2[] = "01aSDf67b"; + char buffer3[] = "01AsdF67C"; EATEST_VERIFY(Stricmp(buffer1, buffer1) == 0); EATEST_VERIFY(Stricmp(buffer2, buffer1) > 0); @@ -1777,13 +1777,13 @@ static int TestStringCore() } - // int Strnicmp(const char8_t* pString1, const char8_t* pString2, size_t n); + // int Strnicmp(const char* pString1, const char* pString2, size_t n); // int Strnicmp(const char16_t* pString1, const char16_t* pString2, size_t n); // int Strnicmp(const char32_t* pString1, const char32_t* pString2, size_t n); { - char8_t buffer1[] = "01asdf67AAsWE"; - char8_t buffer2[] = "01aSDf67basWe"; - char8_t buffer3[] = "01AsdF67CaSwe"; + char buffer1[] = "01asdf67AAsWE"; + char buffer2[] = "01aSDf67basWe"; + char buffer3[] = "01AsdF67CaSwe"; EATEST_VERIFY(Strnicmp(buffer1, buffer1, 13) == 0); EATEST_VERIFY(Strnicmp(buffer2, buffer1, 13) > 0); @@ -1815,7 +1815,7 @@ static int TestStringCore() } - // int StrcmpAlnum(const char8_t* pString1, const char8_t* pString2); + // int StrcmpAlnum(const char* pString1, const char* pString2); // int StrcmpAlnum(const char16_t* pString1, const char16_t* pString2); // No 32 bit version because this function is deprecated. { @@ -1856,7 +1856,7 @@ static int TestStringCore() } - // int StricmpAlnum(const char8_t* pString1, const char8_t* pString2); + // int StricmpAlnum(const char* pString1, const char* pString2); // int StricmpAlnum(const char16_t* pString1, const char16_t* pString2); // No 32 bit version because this function is deprecated. { @@ -1897,7 +1897,7 @@ static int TestStringCore() } - // int Strcoll(const char8_t* pString1, const char8_t* pString2); + // int Strcoll(const char* pString1, const char* pString2); // int Strcoll(const char16_t* pString1, const char16_t* pString2); // int Strcoll(const char32_t* pString1, const char32_t* pString2); { @@ -1908,7 +1908,7 @@ static int TestStringCore() } - // int Strncoll(const char8_t* pString1, const char8_t* pString2, size_t n); + // int Strncoll(const char* pString1, const char* pString2, size_t n); // int Strncoll(const char16_t* pString1, const char16_t* pString2, size_t n); // int Strncoll(const char32_t* pString1, const char32_t* pString2, size_t n); { @@ -1919,7 +1919,7 @@ static int TestStringCore() } - // int Stricoll(const char8_t* pString1, const char8_t* pString2); + // int Stricoll(const char* pString1, const char* pString2); // int Stricoll(const char16_t* pString1, const char16_t* pString2); // int Stricoll(const char32_t* pString1, const char32_t* pString2); { @@ -1930,7 +1930,7 @@ static int TestStringCore() } - // int Strnicoll(const char8_t* pString1, const char8_t* pString1, size_t n); + // int Strnicoll(const char* pString1, const char* pString1, size_t n); // int Strnicoll(const char16_t* pString1, const char16_t* pString1, size_t n); // int Strnicoll(const char32_t* pString1, const char32_t* pString1, size_t n); { @@ -1953,11 +1953,11 @@ static int TestEcvt() // These tests all require a buffer of at least 350 in size to be used - // char8_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char8_t* buffer); + // char* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char* buffer); // char16_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char16_t* buffer); // char32_t* EcvtBuf(double dValue, int nDigitCount, int* decimalPos, int* sign, char32_t* buffer); { - char8_t buffer[kEcvtBufMaxSize]; + char buffer[kEcvtBufMaxSize]; int decimalPos, sign; EcvtBuf(1.0, 10, &decimalPos, &sign, buffer); @@ -1979,11 +1979,11 @@ static int TestEcvt() } - // char8_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char8_t* buffer); + // char* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char* buffer); // char16_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char16_t* buffer); // char32_t* FcvtBuf(double dValue, int nDigitCountAfterDecimal, int* decimalPos, int* sign, char32_t* buffer); { - char8_t buffer[kFcvtBufMaxSize]; + char buffer[kFcvtBufMaxSize]; int decimalPos, sign; FcvtBuf(1.0, 10, &decimalPos, &sign, buffer); @@ -2014,11 +2014,11 @@ static int TestItoa() int nErrorCount = 0; - // char8_t* I32toa(int32_t nValue, char8_t* pResult, int nBase); + // char* I32toa(int32_t nValue, char* pResult, int nBase); // char16_t* I32toa(int32_t nValue, char16_t* pResult, int nBase); // char32_t* I32toa(int32_t nValue, char32_t* pResult, int nBase); { - char8_t sn8[32]; + char sn8[32]; EATEST_VERIFY(I32toa(INT32_MIN, sn8, 10) != NULL); // Can't express INT32_MIN as a numeric constant. EATEST_VERIFY_F(Strcmp(sn8, "-2147483648") == 0, "I32toa(INT32_MIN, sn8, 10) failed; produced %s instead of -2147483648", sn8); @@ -2085,11 +2085,11 @@ static int TestItoa() } - // char8_t* U32toa(uint32_t nValue, char8_t* pResult, int nBase); + // char* U32toa(uint32_t nValue, char* pResult, int nBase); // char16_t* U32toa(uint32_t nValue, char16_t* pResult, int nBase); // char32_t* U32toa(uint32_t nValue, char32_t* pResult, int nBase); { - char8_t sn8[32]; + char sn8[32]; EATEST_VERIFY(U32toa(0, sn8, 10) != NULL); EATEST_VERIFY(Strcmp(sn8, "0") == 0); @@ -2150,11 +2150,11 @@ static int TestItoa() } - // char8_t* I64toa(int64_t nValue, char8_t* pBuffer, int nBase); + // char* I64toa(int64_t nValue, char* pBuffer, int nBase); // char16_t* I64toa(int64_t nValue, char16_t* pBuffer, int nBase); // char32_t* I64toa(int64_t nValue, char32_t* pBuffer, int nBase); { - char8_t sn8[128]; + char sn8[128]; EATEST_VERIFY(I64toa(INT64_MIN, sn8, 10) != NULL); // Can't express INT64_MIN as a numeric constant. EATEST_VERIFY(Strcmp(sn8, "-9223372036854775808") == 0); @@ -2215,11 +2215,11 @@ static int TestItoa() } - // char8_t* U64toa(uint64_t nValue, char8_t* pBuffer, int nBase); + // char* U64toa(uint64_t nValue, char* pBuffer, int nBase); // char16_t* U64toa(uint64_t nValue, char16_t* pBuffer, int nBase); // char32_t* U64toa(uint64_t nValue, char32_t* pBuffer, int nBase); { - char8_t sn8[128]; + char sn8[128]; EATEST_VERIFY(U64toa(0, sn8, 10) != NULL); EATEST_VERIFY(Strcmp(sn8, "0") == 0); @@ -2289,12 +2289,12 @@ static int TestStrtod() int nErrorCount = 0; - // double StrtodEnglish(const char8_t* pString, char8_t** ppStringEnd); + // double StrtodEnglish(const char* pString, char** ppStringEnd); // double StrtodEnglish(const char16_t* pString, char16_t** ppStringEnd); // double StrtodEnglish(const char32_t* pString, char32_t** ppStringEnd); { - const char8_t* p; - char8_t* pEnd = NULL; + const char* p; + char* pEnd = NULL; p = ""; EATEST_VERIFY(0 == StrtodEnglish(p, &pEnd)); @@ -2462,18 +2462,18 @@ static int TestStrtod() } - // double Strtod(const char8_t* pString, char8_t** ppStringEnd); + // double Strtod(const char* pString, char** ppStringEnd); // double Strtod(const char16_t* pString, char16_t** ppStringEnd); // double Strtod(const char32_t* pString, char32_t** ppStringEnd); { - char8_t sn18[] = "-111.111"; - char8_t* pEnd = NULL; + char sn18[] = "-111.111"; + char* pEnd = NULL; EATEST_VERIFY(DoubleEqual(-111.111, Strtod(sn18, &pEnd))); - char8_t sn28[] = "111e111"; + char sn28[] = "111e111"; EATEST_VERIFY(DoubleEqual(111e111, Strtod(sn28, &pEnd))); - char8_t sn38[] = "-111e-111"; + char sn38[] = "-111e-111"; EATEST_VERIFY(DoubleEqual(-111e-111, Strtod(sn38, &pEnd))); } { @@ -2509,23 +2509,23 @@ static int TestStrtoi() int nErrorCount = 0; - // int64_t StrtoI64(const char8_t* pString, char8_t** ppStringEnd, int nBase); + // int64_t StrtoI64(const char* pString, char** ppStringEnd, int nBase); // int64_t StrtoI64(const char16_t* pString, char16_t** ppStringEnd, int nBase); // int64_t StrtoI64(const char32_t* pString, char32_t** ppStringEnd, int nBase); { int64_t result; - char8_t sn18[] = "-1011101110111011101"; - char8_t* pEnd = NULL; + char sn18[] = "-1011101110111011101"; + char* pEnd = NULL; EATEST_VERIFY(INT64_C(-1011101110111011101) == StrtoI64(sn18, &pEnd, 10)); - char8_t sn28[] = "7fffabcdffffabcd"; + char sn28[] = "7fffabcdffffabcd"; EATEST_VERIFY(UINT64_C(0x7fffabcdffffabcd) == StrtoI64(sn28, &pEnd, 16)); - char8_t sn38[] = "101110011011101110111001010000111111100001100101"; + char sn38[] = "101110011011101110111001010000111111100001100101"; EATEST_VERIFY(UINT64_C(0xB9BBB943F865) == StrtoI64(sn38, &pEnd, 2)); - char8_t sn1[] = "1"; + char sn1[] = "1"; for(int base = 2; base <= 36; base++) { result = StrtoI64(sn1, &pEnd, base); @@ -2534,10 +2534,10 @@ static int TestStrtoi() { // Exercize the ability to read extreme values for various bases. - char8_t pINT64_MIN_10_[] = "-9223372036854775809"; // One less than valid. - char8_t pINT64_MIN_10[] = "-9223372036854775808"; - char8_t pINT64_MAX_10[] = "+9223372036854775807"; - char8_t pINT64_MAX_10_[] = "+9223372036854775808"; // One more than valid. + char pINT64_MIN_10_[] = "-9223372036854775809"; // One less than valid. + char pINT64_MIN_10[] = "-9223372036854775808"; + char pINT64_MAX_10[] = "+9223372036854775807"; + char pINT64_MAX_10_[] = "+9223372036854775808"; // One more than valid. errno = 0; result = StrtoI64(pINT64_MIN_10_, &pEnd, 10); @@ -2556,10 +2556,10 @@ static int TestStrtoi() EATEST_VERIFY((result == INT64_MAX) && (errno == ERANGE)); - char8_t pINT64_MIN_16_[] = "-8000000000000001"; // One less than valid. - char8_t pINT64_MIN_16[] = "-8000000000000000"; - char8_t pINT64_MAX_16[] = "+7fffffffffffffff"; - char8_t pINT64_MAX_16_[] = "+8000000000000000"; // One more than valid. + char pINT64_MIN_16_[] = "-8000000000000001"; // One less than valid. + char pINT64_MIN_16[] = "-8000000000000000"; + char pINT64_MAX_16[] = "+7fffffffffffffff"; + char pINT64_MAX_16_[] = "+8000000000000000"; // One more than valid. errno = 0; result = StrtoI64(pINT64_MIN_16_, &pEnd, 16); @@ -2712,28 +2712,28 @@ static int TestStrtoi() } - // uint64_t StrtoU64(const char8_t* pString, char8_t** ppStringEnd, int nBase); + // uint64_t StrtoU64(const char* pString, char** ppStringEnd, int nBase); // uint64_t StrtoU64(const char16_t* pString, char16_t** ppStringEnd, int nBase); // uint64_t StrtoU64(const char32_t* pString, char32_t** ppStringEnd, int nBase); { uint64_t result; - char8_t sn28[] = "7fffabcdffffabcd"; - char8_t* pEnd = NULL; + char sn28[] = "7fffabcdffffabcd"; + char* pEnd = NULL; EATEST_VERIFY(UINT64_C(0x7fffabcdffffabcd) == StrtoU64(sn28, &pEnd, 16)); - char8_t sn38[] = "101110011011101110111001010000111111100001100101"; + char sn38[] = "101110011011101110111001010000111111100001100101"; EATEST_VERIFY(UINT64_C(0xB9BBB943F865) == StrtoU64(sn38, &pEnd, 2)); - char8_t sn48[] = "eb59a646c232da81"; + char sn48[] = "eb59a646c232da81"; EATEST_VERIFY(UINT64_C(0xeb59a646c232da81) == StrtoU64(sn48, &pEnd, 16)); { // Exercize the ability to read extreme values for various bases. - //char8_t pUINT64_MIN_10_[] = "-1"; - char8_t pUINT64_MIN_10[] = "0"; - char8_t pUINT64_MAX_10[] = "18446744073709551615"; - char8_t pUINT64_MAX_10_[] = "18446744073709551616"; + //char pUINT64_MIN_10_[] = "-1"; + char pUINT64_MIN_10[] = "0"; + char pUINT64_MAX_10[] = "18446744073709551615"; + char pUINT64_MAX_10_[] = "18446744073709551616"; // -1 converting to 18446744073709551615 seems to be what conforming Standard C libraries do. So we allow it too. //errno = 0; @@ -2754,10 +2754,10 @@ static int TestStrtoi() - //char8_t pUINT64_MIN_16_[] = "-1"; - char8_t pUINT64_MIN_16[] = "0"; - char8_t pUINT64_MAX_16[] = "ffffffffffffffff"; - char8_t pUINT64_MAX_16_[] = "10000000000000000"; + //char pUINT64_MIN_16_[] = "-1"; + char pUINT64_MIN_16[] = "0"; + char pUINT64_MAX_16[] = "ffffffffffffffff"; + char pUINT64_MAX_16_[] = "10000000000000000"; // -1 converting to 18446744073709551615 seems to be what conforming Standard C libraries do. So we allow it too. //errno = 0; @@ -2801,34 +2801,34 @@ static int TestStrtoi() } - // int32_t StrtoI32(const char8_t* pString, char8_t** ppStringEnd, int nBase); + // int32_t StrtoI32(const char* pString, char** ppStringEnd, int nBase); // int32_t StrtoI32(const char16_t* pString, char16_t** ppStringEnd, int nBase); // int32_t StrtoI32(const char32_t* pString, char32_t** ppStringEnd, int nBase); { int32_t result; - char8_t sn18[] = "-1011101110"; - char8_t* pEnd = NULL; + char sn18[] = "-1011101110"; + char* pEnd = NULL; EATEST_VERIFY(-1011101110 == StrtoI32(sn18, &pEnd, 10)); - char8_t sn28[] = "7fffabcd"; + char sn28[] = "7fffabcd"; EATEST_VERIFY(0x7fffabcd == StrtoI32(sn28, &pEnd, 16)); - char8_t sn38[] = "00111001010000111111100001100101"; + char sn38[] = "00111001010000111111100001100101"; EATEST_VERIFY(0x3943F865LL == StrtoI32(sn38, &pEnd, 2)); - char8_t sn48[] = "BEEFEEC0DE"; //number greater than INT32_MAX + char sn48[] = "BEEFEEC0DE"; //number greater than INT32_MAX EATEST_VERIFY(INT32_MAX == StrtoI32(sn48, &pEnd, 16)); - char8_t sn58[] = "-BAEBEEC0DE"; //number less than INT32_MIN + char sn58[] = "-BAEBEEC0DE"; //number less than INT32_MIN EATEST_VERIFY(INT32_MIN == StrtoI32(sn58, &pEnd, 16)); { // Exercize the ability to read extreme values for various bases. - char8_t pINT32_MIN_10_[] = "-2147483649"; - char8_t pINT32_MIN_10[] = "-2147483648"; - char8_t pINT32_MAX_10[] = "+2147483647"; - char8_t pINT32_MAX_10_[] = "+2147483648"; + char pINT32_MIN_10_[] = "-2147483649"; + char pINT32_MIN_10[] = "-2147483648"; + char pINT32_MAX_10[] = "+2147483647"; + char pINT32_MAX_10_[] = "+2147483648"; errno = 0; result = StrtoI32(pINT32_MIN_10_, &pEnd, 10); @@ -2848,10 +2848,10 @@ static int TestStrtoi() - char8_t pINT32_MIN_16_[] = "-80000001"; - char8_t pINT32_MIN_16[] = "-80000000"; - char8_t pINT32_MAX_16[] = "+7fffffff"; - char8_t pINT32_MAX_16_[] = "+80000000"; + char pINT32_MIN_16_[] = "-80000001"; + char pINT32_MIN_16[] = "-80000000"; + char pINT32_MAX_16[] = "+7fffffff"; + char pINT32_MAX_16_[] = "+80000000"; errno = 0; result = StrtoI32(pINT32_MIN_16_, &pEnd, 16); @@ -2906,29 +2906,29 @@ static int TestStrtoi() } - // uint32_t StrtoU32(const char8_t* pString, char8_t** ppStringEnd, int nBase); - // uint32_t StrtoU32(const char8_t* pString, char16_t** ppStringEnd, int nBase); - // uint32_t StrtoU32(const char8_t* pString, char32_t** ppStringEnd, int nBase); + // uint32_t StrtoU32(const char* pString, char** ppStringEnd, int nBase); + // uint32_t StrtoU32(const char* pString, char16_t** ppStringEnd, int nBase); + // uint32_t StrtoU32(const char* pString, char32_t** ppStringEnd, int nBase); { uint32_t result; - char8_t sn28[] = "7fffabcd"; - char8_t* pEnd = NULL; + char sn28[] = "7fffabcd"; + char* pEnd = NULL; EATEST_VERIFY(0x7fffabcd == StrtoU32(sn28, &pEnd, 16)); - char8_t sn38[] = "10111001010000111111100001100101"; + char sn38[] = "10111001010000111111100001100101"; EATEST_VERIFY(0xB943F865LL == StrtoU32(sn38, &pEnd, 2)); - char8_t sn48[] = "BEEFEEC0DE"; //number greater than UINT32_MAX + char sn48[] = "BEEFEEC0DE"; //number greater than UINT32_MAX EATEST_VERIFY(UINT32_MAX == StrtoU32(sn48, &pEnd, 16)); { // Exercize the ability to read extreme values for various bases. - //char8_t pUINT32_MIN_10_[] = "-1"; - char8_t pUINT32_MIN_10[] = "0"; - char8_t pUINT32_MAX_10[] = "4294967295"; - char8_t pUINT32_MAX_10_[] = "4294967296"; + //char pUINT32_MIN_10_[] = "-1"; + char pUINT32_MIN_10[] = "0"; + char pUINT32_MAX_10[] = "4294967295"; + char pUINT32_MAX_10_[] = "4294967296"; // -1 converting to 18446744073709551615 seems to be what conforming Standard C libraries do. So we allow it too. //errno = 0; @@ -2948,10 +2948,10 @@ static int TestStrtoi() EATEST_VERIFY((result == UINT32_MAX) && (errno == ERANGE)); - //char8_t pUINT32_MIN_16_[] = "-1"; - char8_t pUINT32_MIN_16[] = "0"; - char8_t pUINT32_MAX_16[] = "ffffffff"; - char8_t pUINT32_MAX_16_[] = "100000000"; + //char pUINT32_MIN_16_[] = "-1"; + char pUINT32_MIN_16[] = "0"; + char pUINT32_MAX_16[] = "ffffffff"; + char pUINT32_MAX_16_[] = "100000000"; // -1 converting to 18446744073709551615 seems to be what conforming Standard C libraries do. So we allow it too. //errno = 0; @@ -2995,17 +2995,17 @@ static int TestStrtoi() } - // int32_t AtoI32(const char8_t* pString); + // int32_t AtoI32(const char* pString); // int32_t AtoI32(const char16_t* pString); // int32_t AtoI32(const char32_t* pString); { - char8_t sn18[] = "-1011101110"; + char sn18[] = "-1011101110"; EATEST_VERIFY(-1011101110 == AtoI32(sn18)); - char8_t sn28[] = "2147483647"; + char sn28[] = "2147483647"; EATEST_VERIFY(INT32_MAX == AtoI32(sn28)); - char8_t sn38[] = "-2147483648"; + char sn38[] = "-2147483648"; EATEST_VERIFY(INT32_MIN == AtoI32(sn38)); } { @@ -3030,11 +3030,11 @@ static int TestStrtoi() } - // uint32_t AtoU32(const char8_t* pString); + // uint32_t AtoU32(const char* pString); // uint32_t AtoU32(const char16_t* pString); // uint32_t AtoU32(const char32_t* pString); { - char8_t sn28[] = "4294967295"; + char sn28[] = "4294967295"; EATEST_VERIFY(UINT32_MAX == AtoU32(sn28)); } { @@ -3047,17 +3047,17 @@ static int TestStrtoi() } - // int64_t AtoI64(const char8_t* pString); + // int64_t AtoI64(const char* pString); // int64_t AtoI64(const char16_t* pString); // int64_t AtoI64(const char32_t* pString); { - char8_t sn18[] = "-1011101110111011101"; + char sn18[] = "-1011101110111011101"; EATEST_VERIFY(-1011101110111011101LL == AtoI64(sn18)); - char8_t sn28[] = "9223372036854775807"; + char sn28[] = "9223372036854775807"; EATEST_VERIFY(INT64_MAX == AtoI64(sn28)); - char8_t sn38[] = "-9223372036854775808"; + char sn38[] = "-9223372036854775808"; EATEST_VERIFY(INT64_MIN == AtoI64(sn38)); } { @@ -3082,11 +3082,11 @@ static int TestStrtoi() } - // uint64_t AtoU64(const char8_t* pString); + // uint64_t AtoU64(const char* pString); // uint64_t AtoU64(const char16_t* pString); // uint64_t AtoU64(const char32_t* pString); { - char8_t sn28[] = "18446744073709551615"; + char sn28[] = "18446744073709551615"; EATEST_VERIFY(UINT64_MAX == AtoU64(sn28)); } { @@ -3108,14 +3108,14 @@ static int TestAtof() int nErrorCount = 0; - // double Atof(const char8_t* pString); + // double Atof(const char* pString); // double Atof(const char16_t* pString); // double Atof(const char32_t* pString); { - const char8_t* kStrMin = "2.2250738585072014e-307"; // DBL_MIN is usually 2.2250738585072014e-308, but some Standard Libraries have trouble converting + const char* kStrMin = "2.2250738585072014e-307"; // DBL_MIN is usually 2.2250738585072014e-308, but some Standard Libraries have trouble converting const double kValMin = 2.2250738585072014e-307; // to and from strings of that value. So we use -307 instead, which is pretty reliably supported. - const char8_t* kStrMax = "1.7976931348623158e+307"; // DBL_MAX is usually 1.7976931348623158e+308. + const char* kStrMax = "1.7976931348623158e+307"; // DBL_MAX is usually 1.7976931348623158e+308. const double kValMax = 1.7976931348623158e+307; { @@ -3145,17 +3145,17 @@ static int TestAtof() } } - // double AtofEnglish(const char8_t* pString); + // double AtofEnglish(const char* pString); // double AtofEnglish(const char16_t* pString); // double AtofEnglish(const char32_t* pString); // // AtofEnglish - this function fails on boundary values for double_t // as it performs some math inside that drives the values to infinity. { - const char8_t* kStrMin = "2.2250738585071e-307"; // DBL_MIN is usually 2.2250738585072014e-308, but some Standard Libraries have trouble converting + const char* kStrMin = "2.2250738585071e-307"; // DBL_MIN is usually 2.2250738585072014e-308, but some Standard Libraries have trouble converting const double kValMin = 2.2250738585071e-307; // to and from strings of that value. So we use -307 instead, which is pretty reliably supported. - const char8_t* kStrMax = "1.7976931348622e+307"; // DBL_MAX is usually 1.7976931348623158e+308. + const char* kStrMax = "1.7976931348622e+307"; // DBL_MAX is usually 1.7976931348623158e+308. const double kValMax = 1.7976931348622e+307; { @@ -3189,11 +3189,11 @@ static int TestFtoa() int nErrorCount = 0; - // char8_t* Ftoa(double dValue, char_t* pResult, int nInputLength, int nPrecision, bool bExponentEnabled); + // char* Ftoa(double dValue, char_t* pResult, int nInputLength, int nPrecision, bool bExponentEnabled); // char16_t* Ftoa(double dValue, char_t* pResult, int nInputLength, int nPrecision, bool bExponentEnabled); // char32_t* Ftoa(double dValue, char_t* pResult, int nInputLength, int nPrecision, bool bExponentEnabled); { - char8_t sn18[128]; + char sn18[128]; Ftoa(-1.7976931, sn18, 128, 7, false); if(Strcmp("-1.7976931", sn18) != 0) @@ -3287,12 +3287,12 @@ static int TestFtoa() } - // char8_t* FtoaEnglish(double dValue, char8_t* pResult, int nInputLength, int nPrecision, bool bExponentEnabled); + // char* FtoaEnglish(double dValue, char* pResult, int nInputLength, int nPrecision, bool bExponentEnabled); // char16_t* FtoaEnglish(double dValue, char16_t* pResult, int nInputLength, int nPrecision, bool bExponentEnabled); // char32_t* FtoaEnglish(double dValue, char32_t* pResult, int nInputLength, int nPrecision, bool bExponentEnabled); { - char8_t sn18[128]; - char8_t* pResult; + char sn18[128]; + char* pResult; pResult = FtoaEnglish(-1.7976931, sn18, 128, 7, false); EATEST_VERIFY(pResult && (Strcmp("-1.7976931", sn18) == 0)); @@ -3466,11 +3466,11 @@ static int TestReduceFloatString() int nErrorCount = 0; - // size_t ReduceFloatString(char8_t* pString, size_t nLength = (size_t)~0); + // size_t ReduceFloatString(char* pString, size_t nLength = (size_t)~0); // size_t ReduceFloatString(char16_t* pString, size_t nLength = (size_t)~0); // size_t ReduceFloatString(char32_t* pString, size_t nLength = (size_t)~0); { - char8_t pBuffer[64]; + char pBuffer[64]; size_t n; Strcpy(pBuffer, "2.3400"); @@ -3625,7 +3625,7 @@ static int TestConvertString() { int nErrorCount = 0; - eastl::string8 s8("hello world"); + eastl::string8 s8 = EA_CHAR8("hello world"); eastl::string16 s16; eastl::string32 s32; @@ -3639,13 +3639,13 @@ static int TestConvertString() // 16 -> 8 EA::StdC::Strlcpy(s8, s16); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s16.clear(); // 8 -> 16 // Note that using this non-const string causes this specialization to be called instead of the specialization that takes const Source*. - char8_t pNonConstString8[] = "hello world"; + char pNonConstString8[] = "hello world"; EA::StdC::Strlcpy(s16, pNonConstString8); EATEST_VERIFY(s16 == EA_CHAR16("hello world")); s8.clear(); @@ -3654,7 +3654,7 @@ static int TestConvertString() // Note that using this non-const string causes this specialization to be called instead of the specialization that takes const Source*. char16_t pNonConstString16[] = EA_CHAR16("hello world"); EA::StdC::Strlcpy(s8, pNonConstString16); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s16.clear(); } { @@ -3665,13 +3665,13 @@ static int TestConvertString() // 32 -> 8 EA::StdC::Strlcpy(s8, s32); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s32.clear(); } { // 8 -> 8 - EA::StdC::Strlcpy(s8, eastl::string8("hello world")); - EATEST_VERIFY(s8 == "hello world"); + EA::StdC::Strlcpy(s8, eastl::string8(EA_CHAR8("hello world"))); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s8.clear(); // 16 -> 16 @@ -3690,14 +3690,14 @@ static int TestConvertString() // inline bool Strlcpy(Dest& d, const Source* pSource, size_t sourceLength = (size_t)~0); { // 8 -> 16 - s8 = "hello world"; + s8 = EA_CHAR8("hello world"); EA::StdC::Strlcpy(s16, s8.c_str(), s8.length()); EATEST_VERIFY(s16 == EA_CHAR16("hello world")); s8.clear(); // 16 -> 8 EA::StdC::Strlcpy(s8, s16.c_str(), s16.length()); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s16.clear(); } { @@ -3708,13 +3708,13 @@ static int TestConvertString() // 32 -> 8 EA::StdC::Strlcpy(s8, s32.c_str(), s32.length()); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s32.clear(); } { // 8 -> 8 EA::StdC::Strlcpy(s8, "hello world", 11); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s8.clear(); // 16 -> 16 @@ -3733,14 +3733,14 @@ static int TestConvertString() // inline Dest Strlcpy(const Source& s); { // 8 -> 16 - s8 = "hello world"; + s8 = EA_CHAR8("hello world"); s16 = EA::StdC::Strlcpy(s8); EATEST_VERIFY(s16 == EA_CHAR16("hello world")); s8.clear(); // 16 -> 8 s8 = EA::StdC::Strlcpy(s16); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s16.clear(); } { @@ -3751,13 +3751,13 @@ static int TestConvertString() // 32 -> 8 s8 = EA::StdC::Strlcpy(s32); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s32.clear(); } { // 8 -> 8 - s8 = EA::StdC::Strlcpy(eastl::string8("hello world")); - EATEST_VERIFY(s8 == "hello world"); + s8 = EA::StdC::Strlcpy(eastl::string8(EA_CHAR8("hello world"))); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s8.clear(); // 16 -> 16 @@ -3775,30 +3775,30 @@ static int TestConvertString() // inline Dest Strlcpy(Dest& d, const Source* pSource, size_t sourceLength = (size_t)~0); { // 8 -> 16 - s16 = EA::StdC::Strlcpy("hello world", 11); + s16 = EA::StdC::Strlcpy("hello world", 11); EATEST_VERIFY(s16 == EA_CHAR16("hello world")); s8.clear(); // 16 -> 8 s8 = EA::StdC::Strlcpy(EA_CHAR16("hello world"), 11); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s16.clear(); } { // 8 -> 32 - s32 = EA::StdC::Strlcpy("hello world", 11); + s32 = EA::StdC::Strlcpy("hello world", 11); EATEST_VERIFY(s32 == EA_CHAR32("hello world")); s8.clear(); // 32 -> 8 s8 = EA::StdC::Strlcpy(EA_CHAR32("hello world"), 11); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s32.clear(); } { // 8 -> 8 - s8 = EA::StdC::Strlcpy("hello world", 11); - EATEST_VERIFY(s8 == "hello world"); + s8 = EA::StdC::Strlcpy("hello world", 11); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s8.clear(); // 16 -> 16 @@ -3818,30 +3818,30 @@ static int TestConvertString() { // 8 -> 16 s16 = EA_CHAR16("abc "); - EA::StdC::Strlcat(s16, eastl::string8("hello world")); + EA::StdC::Strlcat(s16, eastl::string8(EA_CHAR8("hello world"))); EATEST_VERIFY(s16 == EA_CHAR16("abc hello world")); // 16 -> 8 - s8 = "abc "; + s8 = EA_CHAR8("abc "); EA::StdC::Strlcat(s8, eastl::string16(EA_CHAR16("hello world"))); - EATEST_VERIFY(s8 == "abc hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("abc hello world")); } { // 8 -> 32 s32 = EA_CHAR32("abc "); - EA::StdC::Strlcat(s32, eastl::string8("hello world")); + EA::StdC::Strlcat(s32, eastl::string8(EA_CHAR8("hello world"))); EATEST_VERIFY(s32 == EA_CHAR32("abc hello world")); // 32 -> 8 - s8 = "abc "; + s8 = EA_CHAR8("abc "); EA::StdC::Strlcat(s8, eastl::string32(EA_CHAR32("hello world"))); - EATEST_VERIFY(s8 == "abc hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("abc hello world")); } { // 8 -> 8 - s8 = "abc "; - EA::StdC::Strlcat(s8, eastl::string8("hello world")); - EATEST_VERIFY(s8 == "abc hello world"); + s8 = EA_CHAR8("abc "); + EA::StdC::Strlcat(s8, eastl::string8(EA_CHAR8("hello world"))); + EATEST_VERIFY(s8 == EA_CHAR8("abc hello world")); s8.clear(); // 16 -> 16 @@ -3867,9 +3867,9 @@ static int TestConvertString() EATEST_VERIFY(s16 == EA_CHAR16("abc hello world")); // 16 -> 8 - s8 = "abc "; + s8 = EA_CHAR8("abc "); EA::StdC::Strlcat(s8, EA_CHAR16("hello world"), 11); - EATEST_VERIFY(s8 == "abc hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("abc hello world")); } { // 8 -> 32 @@ -3878,15 +3878,15 @@ static int TestConvertString() EATEST_VERIFY(s32 == EA_CHAR32("abc hello world")); // 32 -> 8 - s8 = "abc "; + s8 = EA_CHAR8("abc "); EA::StdC::Strlcat(s8, EA_CHAR32("hello world"), 11); - EATEST_VERIFY(s8 == "abc hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("abc hello world")); } { // 8 -> 8 - s8 = "abc "; + s8 = EA_CHAR8("abc "); EA::StdC::Strlcat(s8, "hello world", 11); - EATEST_VERIFY(s8 == "abc hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("abc hello world")); s8.clear(); // 16 -> 16 @@ -3908,14 +3908,14 @@ static int TestConvertString() // inline bool ConvertString(const Source& s, Dest& d); { // 8 -> 16 - s8 = "hello world"; + s8 = EA_CHAR8("hello world"); EA::StdC::ConvertString(s8, s16); EATEST_VERIFY(s16 == EA_CHAR16("hello world")); s8.clear(); // 16 -> 8 EA::StdC::ConvertString(s16, s8); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s16.clear(); } { @@ -3926,7 +3926,7 @@ static int TestConvertString() // 32 -> 8 EA::StdC::ConvertString(s32, s8); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s32.clear(); } @@ -3941,7 +3941,7 @@ static int TestConvertString() // 16 -> 8 s8 = EA::StdC::ConvertString(s16); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s16.clear(); } { @@ -3952,14 +3952,14 @@ static int TestConvertString() // 32 -> 8 s8 = EA::StdC::ConvertString(s32); - EATEST_VERIFY(s8 == "hello world"); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s32.clear(); } { // 8 -> 8 - s8 = EA::StdC::ConvertString(eastl::string8("hello world")); - EATEST_VERIFY(s8 == "hello world"); + s8 = EA::StdC::ConvertString(eastl::string8(EA_CHAR8("hello world"))); + EATEST_VERIFY(s8 == EA_CHAR8("hello world")); s8.clear(); // 16 -> 16 @@ -3974,7 +3974,7 @@ static int TestConvertString() } { //Regression for user-reported problem. - const char8_t* pPath8 = "/abc/def/ghi/jkl"; + const auto* pPath8 = EA_CHAR8("/abc/def/ghi/jkl"); eastl::string16 path16 = EA::StdC::ConvertString(pPath8); EATEST_VERIFY((path16.length() == EA::StdC::Strlen(pPath8))); } @@ -4125,7 +4125,7 @@ static int TestStrstart() int nErrorCount = 0; - // char8_t + // char EATEST_VERIFY( Strstart("", "")); EATEST_VERIFY( Strstart("a", "")); EATEST_VERIFY(!Strstart("", "a")); @@ -4193,7 +4193,7 @@ static int TestStrend() int nErrorCount = 0; - // char8_t + // char EATEST_VERIFY( Strend("", "")); EATEST_VERIFY( Strend("f", "")); EATEST_VERIFY(!Strend("", "f")); diff --git a/test/source/TestTextUtil.cpp b/test/source/TestTextUtil.cpp index 29340f6..ca8072b 100644 --- a/test/source/TestTextUtil.cpp +++ b/test/source/TestTextUtil.cpp @@ -17,7 +17,7 @@ #endif -typedef eastl::basic_string String8; +typedef eastl::basic_string String8; typedef eastl::basic_string String16; typedef eastl::basic_string String32; @@ -30,10 +30,10 @@ static int TestUTF8() int nErrorCount(0); bool bResult; - const char8_t* pResult; + const char* pResult; char16_t cResult; size_t nResult; - char8_t buffer[32]; + char buffer[32]; // We would need a lot more strings than this to test this functionality well. const uint8_t str1[] = { 0 }; @@ -41,12 +41,12 @@ static int TestUTF8() const uint8_t str3[] = { 0xe8, 0x8f, 0xa4, 0xc8, 0x80, 0x61, 0 }; // 0x83e4, 0x0200, 0x0061 const uint8_t str4[] = { 0x7f, 0xc4, 0x80, 0xef, 0xbf, 0xb0, 0 }; // 0x007f, 0x0100, 0xfff0 - const char8_t* strArray[] = + const char* strArray[] = { - reinterpret_cast(str1), - reinterpret_cast(str2), - reinterpret_cast(str3), - reinterpret_cast(str4) + reinterpret_cast(str1), + reinterpret_cast(str2), + reinterpret_cast(str3), + reinterpret_cast(str4) }; // These represent bad combinations of bytes that any UTF8 decoder should recognize. @@ -62,21 +62,21 @@ static int TestUTF8() //const uint8_t strBad8[] = { 0xed, 0xbf, 0xbf, 0 }; //const uint8_t strBad9[] = { 0xef, 0xbf, 0xbe, 0 }; - const char8_t* strBadArray[] = + const char* strBadArray[] = { - reinterpret_cast(strBad1), - reinterpret_cast(strBad2), - reinterpret_cast(strBad3), - reinterpret_cast(strBad4), - reinterpret_cast(strBad5), - reinterpret_cast(strBad6) - /*, reinterpret_cast(strBad7), - reinterpret_cast(strBad8), - reinterpret_cast(strBad9) */ + reinterpret_cast(strBad1), + reinterpret_cast(strBad2), + reinterpret_cast(strBad3), + reinterpret_cast(strBad4), + reinterpret_cast(strBad5), + reinterpret_cast(strBad6) + /*, reinterpret_cast(strBad7), + reinterpret_cast(strBad8), + reinterpret_cast(strBad9) */ }; - // bool UTF8Validate(const char8_t* p, size_t nLength); + // bool UTF8Validate(const char* p, size_t nLength); for(size_t i = 0; i < sizeof(strArray)/sizeof(strArray[0]); ++i) { bResult = UTF8Validate(strArray[i], strlen(strArray[i])); @@ -90,8 +90,8 @@ static int TestUTF8() } - // char8_t* UTF8Increment(const char8_t* p, size_t n); - // char8_t* UTF8Decrement(const char8_t* p, size_t n); + // char* UTF8Increment(const char* p, size_t n); + // char* UTF8Decrement(const char* p, size_t n); pResult = UTF8Increment(strArray[0], 1); EATEST_VERIFY(pResult == (strArray[0] + 1)); pResult = UTF8Decrement(pResult, 1); @@ -113,7 +113,7 @@ static int TestUTF8() EATEST_VERIFY(pResult == strArray[3]); - // size_t UTF8Length(const char8_t* p); + // size_t UTF8Length(const char* p); EATEST_VERIFY(UTF8Length("0123456789") == 10); EATEST_VERIFY(UTF8Length("") == 0); EATEST_VERIFY(UTF8Length("\xc2" "\xa2") == 1); @@ -155,7 +155,7 @@ static int TestUTF8() EATEST_VERIFY(UTF8Length(s32.c_str()) == 9); - // size_t UTF8CharSize(const char8_t* p); + // size_t UTF8CharSize(const char* p); EATEST_VERIFY(UTF8CharSize(strArray[0]) == 1); EATEST_VERIFY(UTF8CharSize(strArray[1]) == 1); EATEST_VERIFY(UTF8CharSize(strArray[2] + 0) == 3); @@ -204,7 +204,7 @@ static int TestUTF8() EATEST_VERIFY(nResult == 3); - // char16_t UTF8ReadChar(const char8_t* p, const char8_t** ppEnd = NULL); + // char16_t UTF8ReadChar(const char* p, const char** ppEnd = NULL); pResult = strArray[0]; cResult = UTF8ReadChar(pResult, &pResult); EATEST_VERIFY((cResult == 0x0000) && (pResult == strArray[0] + 1)); @@ -237,63 +237,63 @@ static int TestUTF8() EATEST_VERIFY((cResult == 0xfff0) && (pResult == strArray[3] + 6)); - // char8_t* UTF8WriteChar(char8_t* p, char16_t c); + // char* UTF8WriteChar(char* p, char16_t c); pResult = buffer; - pResult = UTF8WriteChar((char8_t*)pResult, (char16_t)0x83e4); - pResult = UTF8WriteChar((char8_t*)pResult, (char16_t)0x0200); - pResult = UTF8WriteChar((char8_t*)pResult, (char16_t)0x0061); - pResult = UTF8WriteChar((char8_t*)pResult, (char16_t)0x0000); + pResult = UTF8WriteChar((char*)pResult, (char16_t)0x83e4); + pResult = UTF8WriteChar((char*)pResult, (char16_t)0x0200); + pResult = UTF8WriteChar((char*)pResult, (char16_t)0x0061); + pResult = UTF8WriteChar((char*)pResult, (char16_t)0x0000); EATEST_VERIFY((strcmp(buffer, strArray[2]) == 0) && (pResult == buffer + 7)); - // char8_t* UTF8WriteChar(char8_t* p, char32_t c); + // char* UTF8WriteChar(char* p, char32_t c); pResult = buffer; - pResult = UTF8WriteChar((char8_t*)pResult, (char32_t)0x83e4); - pResult = UTF8WriteChar((char8_t*)pResult, (char32_t)0x0200); - pResult = UTF8WriteChar((char8_t*)pResult, (char32_t)0x0061); - pResult = UTF8WriteChar((char8_t*)pResult, (char32_t)0x0000); + pResult = UTF8WriteChar((char*)pResult, (char32_t)0x83e4); + pResult = UTF8WriteChar((char*)pResult, (char32_t)0x0200); + pResult = UTF8WriteChar((char*)pResult, (char32_t)0x0061); + pResult = UTF8WriteChar((char*)pResult, (char32_t)0x0000); EATEST_VERIFY((strcmp(buffer, strArray[2]) == 0) && (pResult == buffer + 7)); - // bool UTF8IsSoloByte(char8_t c); + // bool UTF8IsSoloByte(char c); EATEST_VERIFY( UTF8IsSoloByte('\0')); EATEST_VERIFY( UTF8IsSoloByte('\n')); EATEST_VERIFY( UTF8IsSoloByte('a')); - EATEST_VERIFY( UTF8IsSoloByte((char8_t)0x7f)); - EATEST_VERIFY(!UTF8IsSoloByte((char8_t)0x80)); - EATEST_VERIFY(!UTF8IsSoloByte((char8_t)0xfd)); - EATEST_VERIFY(!UTF8IsSoloByte((char8_t)0xfe)); - EATEST_VERIFY(!UTF8IsSoloByte((char8_t)0xff)); + EATEST_VERIFY( UTF8IsSoloByte((char)0x7f)); + EATEST_VERIFY(!UTF8IsSoloByte((char)0x80)); + EATEST_VERIFY(!UTF8IsSoloByte((char)0xfd)); + EATEST_VERIFY(!UTF8IsSoloByte((char)0xfe)); + EATEST_VERIFY(!UTF8IsSoloByte((char)0xff)); - // bool UTF8IsLeadByte(char8_t c); + // bool UTF8IsLeadByte(char c); EATEST_VERIFY( UTF8IsSoloByte('\0')); EATEST_VERIFY( UTF8IsSoloByte('\n')); EATEST_VERIFY( UTF8IsSoloByte('a')); - EATEST_VERIFY( UTF8IsSoloByte((char8_t)0x7f)); - EATEST_VERIFY(!UTF8IsSoloByte((char8_t)0xc0)); - EATEST_VERIFY(!UTF8IsSoloByte((char8_t)0xd1)); - EATEST_VERIFY(!UTF8IsSoloByte((char8_t)0xe4)); - EATEST_VERIFY(!UTF8IsSoloByte((char8_t)0xf0)); // This assumes that we don't support 4, 5, 6 byte sequences. - EATEST_VERIFY(!UTF8IsSoloByte((char8_t)0xfe)); - EATEST_VERIFY(!UTF8IsSoloByte((char8_t)0xff)); - - - // bool UTF8IsFollowByte(char8_t c); - EATEST_VERIFY(!UTF8IsFollowByte((char8_t)0x00)); - EATEST_VERIFY(!UTF8IsFollowByte((char8_t)0x7f)); - EATEST_VERIFY( UTF8IsFollowByte((char8_t)0x80)); - EATEST_VERIFY( UTF8IsFollowByte((char8_t)0xbf)); - EATEST_VERIFY(!UTF8IsFollowByte((char8_t)0xc0)); - EATEST_VERIFY(!UTF8IsFollowByte((char8_t)0xff)); - - // char8_t* UTF8ReplaceInvalidChar(char8_t* pIn, size_t nLength, char8_t replaceWith); + EATEST_VERIFY( UTF8IsSoloByte((char)0x7f)); + EATEST_VERIFY(!UTF8IsSoloByte((char)0xc0)); + EATEST_VERIFY(!UTF8IsSoloByte((char)0xd1)); + EATEST_VERIFY(!UTF8IsSoloByte((char)0xe4)); + EATEST_VERIFY(!UTF8IsSoloByte((char)0xf0)); // This assumes that we don't support 4, 5, 6 byte sequences. + EATEST_VERIFY(!UTF8IsSoloByte((char)0xfe)); + EATEST_VERIFY(!UTF8IsSoloByte((char)0xff)); + + + // bool UTF8IsFollowByte(char c); + EATEST_VERIFY(!UTF8IsFollowByte((char)0x00)); + EATEST_VERIFY(!UTF8IsFollowByte((char)0x7f)); + EATEST_VERIFY( UTF8IsFollowByte((char)0x80)); + EATEST_VERIFY( UTF8IsFollowByte((char)0xbf)); + EATEST_VERIFY(!UTF8IsFollowByte((char)0xc0)); + EATEST_VERIFY(!UTF8IsFollowByte((char)0xff)); + + // char* UTF8ReplaceInvalidChar(char* pIn, size_t nLength, char replaceWith); { - char outBuffer[256] = {0}; - { - auto* pBad = u8"foofoobaazong"; - auto* pGood = u8"foofoobaazong"; + char8_t outBuffer[256] = {0}; + + auto* pBad = EA_CHAR8("foofoobaazong"); + auto* pGood = EA_CHAR8("foofoobaazong"); auto* pOut = UTF8ReplaceInvalidChar(pBad, UTF8Length(pBad), outBuffer, '?'); @@ -302,6 +302,8 @@ static int TestUTF8() } { + char outBuffer[256] = {0}; + auto* pBad = "foofoo\xfa" "baazong"; auto* pGood = "foofoo?baazong"; @@ -313,6 +315,8 @@ static int TestUTF8() { + char outBuffer[256] = {0}; + auto* pBad = "foofoo\xfa\xfa\xfa\xfa\xfa" "baazong"; auto* pGood = "foofoo?????baazong"; @@ -323,6 +327,8 @@ static int TestUTF8() } { + char outBuffer[256] = {0}; + auto* pBad = "foo\xfa" "foo\xfa\xfa" "b\xfa" "a\xfa" "a\xfa" "z\xfa" "o\xfa" "n\xfa" "g\xfa"; auto* pGood = "foo?foo??b?a?a?z?o?n?g?"; @@ -350,7 +356,7 @@ int TestTextUtil() // WildcardMatch { - // char8_t + // char EATEST_VERIFY(WildcardMatch("abcde", "*e", false) == true); EATEST_VERIFY(WildcardMatch("abcde", "*f", false) == false); EATEST_VERIFY(WildcardMatch("abcde", "???de", false) == true); @@ -415,8 +421,8 @@ int TestTextUtil() } - // EASTDC_API bool ParseDelimitedText(const char8_t* pText, const char8_t* pTextEnd, char8_t cDelimiter, - // const char8_t*& pToken, const char8_t*& pTokenEnd, const char8_t** ppNewText); + // EASTDC_API bool ParseDelimitedText(const char* pText, const char* pTextEnd, char cDelimiter, + // const char*& pToken, const char*& pTokenEnd, const char** ppNewText); // EASTDC_API bool ParseDelimitedText(const char16_t* pText, const char16_t* pTextEnd, char16_t cDelimiter, // const char16_t*& pToken, const char16_t*& pTokenEnd, const char16_t** ppNewText); // EASTDC_API bool ParseDelimitedText(const char32_t* pText, const char32_t* pTextEnd, char32_t cDelimiter, @@ -503,7 +509,7 @@ int TestTextUtil() // ConvertBinaryDataToASCIIArray / ConvertASCIIArrayToBinaryData { uint8_t data[4] = { 0x12, 0x34, 0x56, 0x78 }; - char8_t result8[32]; + char result8[32]; char16_t result16[32]; char32_t result32[32]; @@ -547,20 +553,20 @@ int TestTextUtil() } - // EASTDC_API const char8_t* GetTextLine(const char8_t* pText, const char8_t* pTextEnd, const char8_t** ppNewText); + // EASTDC_API const char* GetTextLine(const char* pText, const char* pTextEnd, const char** ppNewText); { - const char8_t* p1 = ""; - const char8_t* p2 = "\n"; - const char8_t* p3 = "\r\n"; - const char8_t* p4 = "\r\n\n"; - const char8_t* p5 = "\n\r\r"; - const char8_t* p6 = "aaa\nbbb\rccc\r\nddd"; - const char8_t* p7 = "aaa\nddd\n"; - const char8_t* p8 = "aaa\nddd\r\n"; - - const char8_t* pLine; - const char8_t* pLineEnd; - const char8_t* pLineNext; + const char* p1 = ""; + const char* p2 = "\n"; + const char* p3 = "\r\n"; + const char* p4 = "\r\n\n"; + const char* p5 = "\n\r\r"; + const char* p6 = "aaa\nbbb\rccc\r\nddd"; + const char* p7 = "aaa\nddd\n"; + const char* p8 = "aaa\nddd\r\n"; + + const char* pLine; + const char* pLineEnd; + const char* pLineNext; pLine = p1; pLineEnd = GetTextLine(pLine, p1 + Strlen(p1), &pLineNext); @@ -810,7 +816,7 @@ int TestTextUtil() - // EASTDC_API bool SplitTokenDelimited(const char8_t* pSource, size_t nSourceLength, char8_t cDelimiter, char8_t* pToken, size_t nTokenLength, const char8_t** ppNewSource = NULL); + // EASTDC_API bool SplitTokenDelimited(const char* pSource, size_t nSourceLength, char cDelimiter, char* pToken, size_t nTokenLength, const char** ppNewSource = NULL); { // To do } @@ -1109,7 +1115,7 @@ int TestTextUtil() } - // EASTDC_API bool SplitTokenSeparated(const char8_t* pSource, size_t nSourceLength, char8_t cDelimiter, char8_t* pToken, size_t nTokenLength, const char8_t** ppNewSource = NULL); + // EASTDC_API bool SplitTokenSeparated(const char* pSource, size_t nSourceLength, char cDelimiter, char* pToken, size_t nTokenLength, const char** ppNewSource = NULL); { // To do }