This commit is contained in:
Sergey Isakov 2020-04-15 22:19:04 +03:00
commit fe29494120
11 changed files with 1008 additions and 281 deletions

View File

@ -35,10 +35,6 @@
9A105B2624464A830006DE06 /* VectorGraphics.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A105B2224464A830006DE06 /* VectorGraphics.h */; };
9A105B2724464A830006DE06 /* VectorGraphics.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A105B2224464A830006DE06 /* VectorGraphics.h */; };
9A105B2824464A830006DE06 /* VectorGraphics.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A105B2224464A830006DE06 /* VectorGraphics.h */; };
9A105B2924464A830006DE06 /* ftol.asm in Sources */ = {isa = PBXBuildFile; fileRef = 9A105B2324464A830006DE06 /* ftol.asm */; };
9A105B2A24464A830006DE06 /* ftol.asm in Sources */ = {isa = PBXBuildFile; fileRef = 9A105B2324464A830006DE06 /* ftol.asm */; };
9A105B2B24464A830006DE06 /* ftol.asm in Sources */ = {isa = PBXBuildFile; fileRef = 9A105B2324464A830006DE06 /* ftol.asm */; };
9A105B2C24464A830006DE06 /* ftol.asm in Sources */ = {isa = PBXBuildFile; fileRef = 9A105B2324464A830006DE06 /* ftol.asm */; };
9A105B2D24464A830006DE06 /* BmLib.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A105B2424464A830006DE06 /* BmLib.h */; };
9A105B2E24464A830006DE06 /* BmLib.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A105B2424464A830006DE06 /* BmLib.h */; };
9A105B2F24464A830006DE06 /* BmLib.h in Headers */ = {isa = PBXBuildFile; fileRef = 9A105B2424464A830006DE06 /* BmLib.h */; };
@ -2121,7 +2117,6 @@
9AC77FC224176C04005CDD5C /* XObjArray_tests.cpp in Sources */,
9AC7808224176C04005CDD5C /* memory.cpp in Sources */,
9AC7803B24176C04005CDD5C /* cpu.cpp in Sources */,
9A105B2924464A830006DE06 /* ftol.asm in Sources */,
9AC7800124176C04005CDD5C /* LegacyBoot.cpp in Sources */,
9AC7807524176C04005CDD5C /* REFIT_MENU_SCREEN.cpp in Sources */,
9AC7801F24176C04005CDD5C /* LegacyBiosThunk.cpp in Sources */,
@ -2239,7 +2234,6 @@
9ACFE6E924309AF80071CC93 /* XObjArray_tests.cpp in Sources */,
9ACFE6EB24309AF80071CC93 /* memory.cpp in Sources */,
9ACFE6EC24309AF80071CC93 /* cpu.cpp in Sources */,
9A105B2C24464A830006DE06 /* ftol.asm in Sources */,
9ACFE6ED24309AF80071CC93 /* LegacyBoot.cpp in Sources */,
9ACFE6EE24309AF80071CC93 /* REFIT_MENU_SCREEN.cpp in Sources */,
9ACFE6EF24309AF80071CC93 /* LegacyBiosThunk.cpp in Sources */,
@ -2357,7 +2351,6 @@
9AF41621242CD75C00D2644C /* memory.cpp in Sources */,
9AF41622242CD75C00D2644C /* cpu.cpp in Sources */,
9AF41623242CD75C00D2644C /* LegacyBoot.cpp in Sources */,
9A105B2A24464A830006DE06 /* ftol.asm in Sources */,
9AF41624242CD75C00D2644C /* REFIT_MENU_SCREEN.cpp in Sources */,
9AF41625242CD75C00D2644C /* LegacyBiosThunk.cpp in Sources */,
9A09863224389A6A00826276 /* menu.cpp in Sources */,
@ -2475,7 +2468,6 @@
9AF416FE242CDA5800D2644C /* memory.cpp in Sources */,
9AF416FF242CDA5800D2644C /* cpu.cpp in Sources */,
9AF41700242CDA5800D2644C /* LegacyBoot.cpp in Sources */,
9A105B2B24464A830006DE06 /* ftol.asm in Sources */,
9AF41701242CDA5800D2644C /* REFIT_MENU_SCREEN.cpp in Sources */,
9AF41702242CDA5800D2644C /* LegacyBiosThunk.cpp in Sources */,
9A09863324389A6A00826276 /* menu.cpp in Sources */,

View File

@ -85,7 +85,6 @@
9ACAB117242623EE00BDB3CF /* printf_lite.c in Sources */ = {isa = PBXBuildFile; fileRef = 9ACAB116242623EE00BDB3CF /* printf_lite.c */; };
9ACAB1192426255C00BDB3CF /* printf_lite.c in Sources */ = {isa = PBXBuildFile; fileRef = 9ACAB116242623EE00BDB3CF /* printf_lite.c */; };
9ACAB11A2426255C00BDB3CF /* printf_lite.c in Sources */ = {isa = PBXBuildFile; fileRef = 9ACAB116242623EE00BDB3CF /* printf_lite.c */; };
9AF41576242CBE7600D2644C /* poolprint-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AF41571242CBE7600D2644C /* poolprint-test.cpp */; };
/* End PBXBuildFile section */
/* Begin PBXCopyFilesBuildPhase section */
@ -536,7 +535,6 @@
9A0B08562402FF7700E2B470 /* XStringWArray.cpp in Sources */,
9A28CD0C241B8DD400F3D247 /* strcmp_test.cpp in Sources */,
9A28CD09241B8DD400F3D247 /* strncmp_test.cpp in Sources */,
9AF41576242CBE7600D2644C /* poolprint-test.cpp in Sources */,
9AC780AE2417DD2F005CDD5C /* panic.cpp in Sources */,
9A0B085F240308E400E2B470 /* XStringW.cpp in Sources */,
9A0B08592402FF8200E2B470 /* all_tests.cpp in Sources */,

View File

@ -81,11 +81,11 @@ void PauseForKey(const wchar_t* msg)
UINTN StrLen(const wchar_t* String)
{
return wchar_len(String);
return size_of_utf_string(String);
}
UINTN StrLen(const char16_t* String)
{
return char16_len(String);
return size_of_utf_string(String);
}

View File

@ -21,7 +21,6 @@
// Macros that directly map functions to BaseLib, BaseMemoryLib, and DebugLib functions
// originally from OpensslLib
#define memcpy(dest,source,count) CopyMem(dest,source,(UINTN)(count))
#define memset(dest,ch,count) SetMem(dest,(UINTN)(count),(UINT8)(ch))
#define memchr(buf,ch,count) ScanMem8(buf,(UINTN)(count),(UINT8)ch)
#define memcmp(buf1,buf2,count) (int)(CompareMem(buf1,buf2,(UINTN)(count)))

View File

@ -10,4 +10,9 @@ inline void* memmove(void *dst, const void *src, size_t len)
return CopyMem(dst, (void*)(src), len);
}
inline void* memcpy(void *dst, const void *src, size_t len)
{
return CopyMem(dst,src,len);
}
#endif

View File

@ -119,7 +119,7 @@ XStringW& XStringW::takeValueFrom(const wchar_t* S)
XStringW& XStringW::takeValueFrom(const char* S)
{
xsize newLen = utf8_string_wchar_count(S);
xsize newLen = utf_size_of_utf_string(m_data, S);
Init(newLen);
wchar_string_from_utf8_string(m_data, m_allocatedSize+1, S); // m_size doesn't count the NULL terminator
SetLength(newLen);

File diff suppressed because it is too large Load Diff

View File

@ -9,6 +9,7 @@
#include <stddef.h>
#include <wchar.h>
#include <string.h>
#ifndef __cplusplus
//typedef uint16_t wchar_t;
@ -16,34 +17,272 @@ typedef uint32_t char32_t;
typedef uint16_t char16_t;
#endif
#ifndef __WCHAR_MAX__
#error __WCHAR_MAX__
#endif
size_t char16_len(const char16_t* s);
size_t char32_len(const char32_t* s);
size_t wchar_len(const wchar_t* s);
#if __WCHAR_MAX__ <= 0xFFFFu
#define wchar_cast char16_t
#else
#define wchar_cast char32_t
#endif
#ifndef wchar_cast
#error wchar_cast
#endif
char32_t get_char32_from_utf8(const char *s);
/*
* len means nb utf32 char
* size means nb of underlying native type (nb of char16_t, nb of char32_t, etc.
*/
/****** utility *****/
/****** utf8 - utf32 *****/
/*
* Size of an UTF32 char when represented in UTF8
* Return value : size
*/
size_t utf8_size_of_utf32_char(char32_t c);
/*
* Increment size and return a pointer to the next char
* Return value : pointer to the end of string or at the error
*/
const char32_t* utf8_size_of_utf32_char_ptr(const char32_t *s, size_t* size);
/*
* Store an utf32 char in dst, if there is enough room (dst_max_len is >= size of utf32 char)
* If there is enough room, dst_max_len is decrement and dst is increment and returned
* If there isn't enough room, dst_max_len is set to 0 and dst is returned
*/
char* get_utf8_from_char32(char* dst, size_t* dst_max_len, char32_t utf32_char);
/*
* char32 will be set to 0 at the end of string or at error
* Return value : pointer to the end of string or at the error
*/
const char* get_char32_from_utf8_string(const char* s, char32_t* char32);
/*
* Size in bytes of an utf32 string if it were converted to utf8
* Return value : pointer to the end of string or at the error
*/
size_t utf8_size_of_utf32_string(const char32_t* s);
/*
* Size in bytes of an utf32 string of len char if it were converted to utf8
* Return value : pointer to the end of string or at the error
*/
size_t utf8_size_of_utf32_string_len(const char32_t* s, size_t len);
size_t utf32_size_of_utf8_string(const char* s);
size_t utf32_size_of_utf8_string_len(const char* s, size_t len);
size_t utf32_string_from_utf8_string(char32_t* dst, size_t dst_max_len, const char* s);
size_t utf8_string_from_utf32_string(char* dst, size_t dst_max_len, const char32_t *s);
/****** utf8 - utf16 *****/
/*
* Increment size
* Return value : pointer to the end of string or at the error
*/
const char16_t* utf8_size_of_utf16_char_ptr(const char16_t *s, size_t* size);
size_t utf8_size_of_utf16_string(const char16_t* s);
size_t utf8_size_of_utf16_string_len(const char16_t* s, size_t len);
size_t utf16_size_of_utf8_string(const char* s);
size_t utf16_size_of_utf8_string_len(const char* s, size_t len);
size_t utf8_string_from_utf16_string(char* dst, size_t dst_max_len, const char16_t *s);
size_t utf16_string_from_utf8_string(char16_t* dst, size_t dst_max_len, const char* s);
/****** utf16 - utf32 *****/
size_t utf16_size_of_utf32_char(char32_t c);
void get_char16_from_char32(char32_t char32, char16_t* char16_1, char16_t* char16_2);
size_t utf8_string_char16_count(const char *src);
size_t char16_string_from_utf8_string(char16_t* dst, size_t dst_max_len, const char *s);
size_t utf8_string_from_char16_string(char* dst, size_t dst_max_len, const char16_t *s);
size_t utf8_string_char32_count(const char *s);
size_t char32_string_from_utf8_string(char32_t* dst, size_t dst_max_len, const char *s);
size_t utf8_string_from_char32_string(char* dst, size_t dst_max_len, const char32_t *s);
char32_t get_char32_from_char16(char16_t char16_1, char16_t char16_2);
const char16_t* get_char32_from_utf16_string(const char16_t* s, char32_t* char32);
size_t utf8_string_wchar_count(const char *src);
size_t wchar_string_from_utf8_string(wchar_t* dst, size_t dst_max_len, const char *s);
size_t utf16_size_of_utf32_string(const char32_t *s);
size_t utf16_size_of_utf32_string_len(const char32_t *s, size_t len);
size_t utf32_size_of_utf16_string(const char16_t *s);
size_t utf32_size_of_utf16_string_len(const char16_t *s, size_t len);
size_t utf16_string_from_utf32_string(char16_t* dst, size_t dst_max_len, const char32_t *s);
size_t utf32_string_from_utf16_string(char32_t* dst, size_t dst_max_len, const char16_t *s);
/****** utf8 - wchar_t *****/
size_t utf8_size_of_wchar_string(const wchar_t* s);
size_t utf8_size_of_wchar_string_len(const wchar_t* s, size_t len);
size_t wchar_size_of_utf8_string(const char* s);
size_t wchar_size_of_utf8_string_len(const char* s, size_t len);
size_t utf8_string_from_wchar_string(char* dst, size_t dst_max_len, const wchar_t* s);
size_t wchar_string_from_utf8_string(wchar_t* dst, size_t dst_max_len, const char* s);
size_t char16_string_char32_count(const char16_t *s);
size_t utf32_string_to_char16_string(char32_t* dst, size_t dst_max_len, const char16_t *s);
size_t utf16_string_to_char32_string(char16_t* dst, size_t dst_max_len, const char32_t *s);
/****** utf16 - wchar_t *****/
size_t utf16_size_of_wchar_string(const wchar_t* s);
size_t utf16_size_of_wchar_string_len(const wchar_t* s, size_t len);
size_t wchar_size_of_utf16_string(const char16_t *s);
size_t wchar_size_of_utf16_string_len(const char16_t *s, size_t len);
size_t utf16_string_from_wchar_string(char16_t* dst, size_t dst_max_len, const wchar_t* s);
size_t wchar_string_from_utf16_string(wchar_t* dst, size_t dst_max_len, const char16_t* s);
/****** utf32 - wchar_t *****/
size_t utf32_size_of_wchar_string(const wchar_t* s);
size_t utf32_size_of_wchar_string_len(const wchar_t* s, size_t len);
size_t wchar_size_of_utf32_string(const char32_t *s);
size_t wchar_size_of_utf32_string_len(const char32_t *s, size_t len);
size_t utf32_string_from_wchar_string(char32_t* dst, size_t dst_max_len, const wchar_t* s);
size_t wchar_string_from_utf32_string(wchar_t* dst, size_t dst_max_len, const char32_t* s);
/****** no conversion *****/
size_t utf8_size_of_utf8_string(const char* s);
size_t utf8_size_of_utf8_string_len(const char* s, size_t len);
size_t utf16_size_of_utf16_string(const char16_t* s);
size_t utf16_size_of_utf16_string_len(const char16_t* s, size_t len);
size_t utf32_size_of_utf32_string(const char32_t* s);
size_t utf32_size_of_utf32_string_len(const char32_t* s, size_t len);
size_t wchar_size_of_wchar_string(const wchar_t* s);
size_t wchar_size_of_wchar_string_len(const wchar_t* s, size_t len);
size_t utf8_string_from_utf8_string(char* dst, size_t dst_max_len, const char *s);
size_t utf16_string_from_utf16_string(char16_t* dst, size_t dst_max_len, const char16_t *s);
size_t utf32_string_from_utf32_string(char32_t* dst, size_t dst_max_len, const char32_t *s);
size_t wchar_string_from_wchar_string(wchar_t* dst, size_t dst_max_len, const wchar_t *s);
/****** convenience *****/
inline size_t length_of_utf8_string(const char* s) {return utf32_size_of_utf8_string(s); }
inline size_t length_of_utf16_string(const char16_t* s) {return utf32_size_of_utf16_string(s); }
inline size_t length_of_utf32_string(const char32_t* s) {return utf32_size_of_utf32_string(s); } // UTF32 length == size
size_t length_of_wchar_string(const wchar_t* s);
#ifdef __cplusplus
inline const char* get_char32_from_string(const char* s, char32_t* char32) { return get_char32_from_utf8_string(s, char32); }
inline const char16_t* get_char32_from_string(const char16_t* s, char32_t* char32) { return get_char32_from_utf16_string(s, char32); }
inline const char32_t* get_char32_from_string(const char32_t* s, char32_t* char32) { *char32 = *s; return s+1; }
inline const wchar_t* get_char32_from_string(const wchar_t* s, char32_t* char32) { return (wchar_t*)get_char32_from_string((wchar_cast*)s, char32); }
inline size_t length_of_utf_string(const char* s) { return utf32_size_of_utf8_string(s); };
inline size_t length_of_utf_string(const char16_t* s) { return utf32_size_of_utf16_string(s); };
inline size_t length_of_utf_string(const char32_t* s) { return utf32_size_of_utf32_string(s); };
inline size_t length_of_utf_string(const wchar_t* s) { return length_of_utf_string((wchar_cast*)s); };
inline size_t size_of_utf_string(const char* s) { return utf8_size_of_utf8_string(s); }
inline size_t size_of_utf_string(const char16_t* s) { return utf16_size_of_utf16_string(s); }
inline size_t size_of_utf_string(const char32_t* s) { return utf32_size_of_utf32_string(s); } // for UTF32 size and length are equal
inline size_t size_of_utf_string(const wchar_t* s) { return size_of_utf_string((wchar_cast*)s); }
inline size_t utf_size_of_utf_string(const char*, const char* s) { return utf8_size_of_utf8_string(s); }
inline size_t utf_size_of_utf_string(const char16_t*, const char* s) { return utf16_size_of_utf8_string(s); }
inline size_t utf_size_of_utf_string(const char32_t*, const char* s) { return utf32_size_of_utf8_string(s); }
inline size_t utf_size_of_utf_string(const wchar_t* t, const char* s) { return utf_size_of_utf_string((wchar_cast*)t, s); }
inline size_t utf_size_of_utf_string(const char*, const char16_t* s) { return utf8_size_of_utf16_string(s); }
inline size_t utf_size_of_utf_string(const char16_t*, const char16_t* s) { return utf16_size_of_utf16_string(s); }
inline size_t utf_size_of_utf_string(const char32_t*, const char16_t* s) { return utf32_size_of_utf16_string(s); }
inline size_t utf_size_of_utf_string(const wchar_t* t, const char16_t* s) { return utf_size_of_utf_string((wchar_cast*)t, s); }
inline size_t utf_size_of_utf_string(const char*, const char32_t* s) { return utf8_size_of_utf32_string(s); }
inline size_t utf_size_of_utf_string(const char16_t*, const char32_t* s) { return utf16_size_of_utf32_string(s); }
inline size_t utf_size_of_utf_string(const char32_t*, const char32_t* s) { return utf32_size_of_utf32_string(s); }
inline size_t utf_size_of_utf_string(const wchar_t* t, const char32_t* s) { return utf_size_of_utf_string((wchar_cast*)t, s); }
inline size_t utf_size_of_utf_string(const char* t, const wchar_t* s) { return utf_size_of_utf_string(t, (wchar_cast*)s); }
inline size_t utf_size_of_utf_string(const char16_t* t, const wchar_t* s) { return utf_size_of_utf_string(t, (wchar_cast*)s); }
inline size_t utf_size_of_utf_string(const char32_t* t, const wchar_t* s) { return utf_size_of_utf_string(t, (wchar_cast*)s); }
inline size_t utf_size_of_utf_string(const wchar_t* t, const wchar_t* s) { return utf_size_of_utf_string(t, (wchar_cast*)s); }
inline size_t size_of_utf_string_len(const char* s, size_t len) { return utf8_size_of_utf8_string_len(s, len); }
inline size_t size_of_utf_string_len(const char16_t* s, size_t len) { return utf16_size_of_utf16_string_len(s, len); }
inline size_t size_of_utf_string_len(const char32_t* s, size_t len) { return utf32_size_of_utf32_string_len(s, len); } // for UTF32 size and length are equal
inline size_t size_of_utf_string_len(const wchar_t* s, size_t len) { return size_of_utf_string_len((wchar_cast*)s, len); }
inline size_t utf_size_of_utf_string_len(const char*, const char* s, size_t len) { return utf8_size_of_utf8_string_len(s, len); }
inline size_t utf_size_of_utf_string_len(const char16_t*, const char* s, size_t len) { return utf16_size_of_utf8_string_len(s, len); }
inline size_t utf_size_of_utf_string_len(const char32_t*, const char* s, size_t len) { return utf32_size_of_utf8_string_len(s, len); }
inline size_t utf_size_of_utf_string_len(const wchar_t* t, const char* s, size_t len) { return utf_size_of_utf_string_len((wchar_cast*)t, s, len); }
inline size_t utf_size_of_utf_string_len(const char*, const char16_t* s, size_t len) { return utf8_size_of_utf16_string_len(s, len); }
inline size_t utf_size_of_utf_string_len(const char16_t*, const char16_t* s, size_t len) { return utf16_size_of_utf16_string_len(s, len); }
inline size_t utf_size_of_utf_string_len(const char32_t*, const char16_t* s, size_t len) { return utf32_size_of_utf16_string_len(s, len); }
inline size_t utf_size_of_utf_string_len(const wchar_t* t, const char16_t* s, size_t len) { return utf_size_of_utf_string_len((wchar_cast*)t, s, len); }
inline size_t utf_size_of_utf_string_len(const char*, const char32_t* s, size_t len) { return utf8_size_of_utf32_string_len(s, len); }
inline size_t utf_size_of_utf_string_len(const char16_t*, const char32_t* s, size_t len) { return utf16_size_of_utf32_string_len(s, len); }
inline size_t utf_size_of_utf_string_len(const char32_t*, const char32_t* s, size_t len) { return utf32_size_of_utf32_string_len(s, len); }
inline size_t utf_size_of_utf_string_len(const wchar_t* t, const char32_t* s, size_t len) { return utf_size_of_utf_string_len((wchar_cast*)t, s, len); }
inline size_t utf_size_of_utf_string_len(const char* t, const wchar_t* s, size_t len) { return utf_size_of_utf_string_len((wchar_cast*)t, (wchar_cast*)s, len); }
inline size_t utf_size_of_utf_string_len(const char16_t* t, const wchar_t* s, size_t len) { return utf_size_of_utf_string_len((wchar_cast*)t, (wchar_cast*)s, len); }
inline size_t utf_size_of_utf_string_len(const char32_t* t, const wchar_t* s, size_t len) { return utf_size_of_utf_string_len((wchar_cast*)t, (wchar_cast*)s, len); }
inline size_t utf_size_of_utf_string_len(const wchar_t* t, const wchar_t* s, size_t len) { return utf_size_of_utf_string_len((wchar_cast*)t, (wchar_cast*)s, len); }
inline size_t utf_string_from_utf_string(char* dst, size_t dst_max_len, const char* s) { return utf8_string_from_utf8_string(dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(char16_t* dst, size_t dst_max_len, const char* s) { return utf16_string_from_utf8_string(dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(char32_t* dst, size_t dst_max_len, const char* s) { return utf32_string_from_utf8_string(dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(wchar_t* dst, size_t dst_max_len, const char* s) { return utf_string_from_utf_string((wchar_cast*)dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(char* dst, size_t dst_max_len, const char16_t *s) { return utf8_string_from_utf16_string(dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(char16_t* dst, size_t dst_max_len, const char16_t *s) { return utf16_string_from_utf16_string(dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(char32_t* dst, size_t dst_max_len, const char16_t *s) { return utf32_string_from_utf16_string(dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(wchar_t* dst, size_t dst_max_len, const char16_t *s) { return utf_string_from_utf_string((wchar_cast*)dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(char* dst, size_t dst_max_len, const char32_t *s) { return utf8_string_from_utf32_string(dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(char16_t* dst, size_t dst_max_len, const char32_t *s) { return utf16_string_from_utf32_string(dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(char32_t* dst, size_t dst_max_len, const char32_t *s) { return utf32_string_from_utf32_string(dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(wchar_t* dst, size_t dst_max_len, const char32_t *s) { return utf_string_from_utf_string((wchar_cast*)dst, dst_max_len, s); }
inline size_t utf_string_from_utf_string(char* dst, size_t dst_max_len, const wchar_t *s) { return utf_string_from_utf_string(dst, dst_max_len, (wchar_cast*)s); }
inline size_t utf_string_from_utf_string(char16_t* dst, size_t dst_max_len, const wchar_t *s) { return utf_string_from_utf_string(dst, dst_max_len, (wchar_cast*)s); }
inline size_t utf_string_from_utf_string(char32_t* dst, size_t dst_max_len, const wchar_t *s) { return utf_string_from_utf_string(dst, dst_max_len, (wchar_cast*)s); }
inline size_t utf_string_from_utf_string(wchar_t* dst, size_t dst_max_len, const wchar_t *s) { return utf_string_from_utf_string(dst, dst_max_len, (wchar_cast*)s); }
#endif // __cplusplus
#undef wchar_cast
#endif /* utf816Conversion_hpp */

View File

@ -68,7 +68,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
wchar_t* wbuf = spc.Str;
va_end(valist);
//delay_ms(10);
if ( memcmp(wbuf, expectResult, wchar_len(expectResult)*sizeof(expectResult[0])) != 0 ) {
if ( memcmp(wbuf, expectResult, size_of_utf_string(expectResult)*sizeof(expectResult[0])) != 0 ) {
// loggf(F(" -> ERROR. Expect " PRILF " and get %ls\n"), expectResult, buf);
// not using wprintf, it crashes sometimes, it doesn't work for short-wchar
loggf(F("%s -> ERROR. Expect "), label);

View File

@ -75,7 +75,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
int vsnwprintf_ret = PRINTF_FUNCTION_NAME(PRINTF_CFUNCTION_PREFIX, vsnwprint, PRINTF_CFUNCTION_SUFFIX)(wbuf, sizeof(wbuf)/sizeof(wchar_t), format, valist);
va_end(valist);
//delay_ms(10);
if ( memcmp(wbuf, expectResult, wchar_len(expectResult)*sizeof(expectResult[0])) != 0 ) {
if ( memcmp(wbuf, expectResult, size_of_utf_string(expectResult)*sizeof(expectResult[0])) != 0 ) {
// loggf(F(" -> ERROR. Expect " PRILF " and get %ls\n"), expectResult, buf);
// not using wprintf, it crashes sometimes, it doesn't work for short-wchar
loggf(F("%s -> ERROR. Expect "), label);

View File

@ -83,7 +83,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
UnicodeVSPrint(wbuf, sizeof(wbuf), format, valist);
va_end(valist);
//delay_ms(10);
if ( memcmp(wbuf, expectResult, wchar_len(expectResult)*sizeof(expectResult[0])) != 0 ) {
if ( memcmp(wbuf, expectResult, size_of_utf_string(expectResult)*sizeof(expectResult[0])) != 0 ) {
// loggf(F(" -> ERROR. Expect " PRILF " and get %ls\n"), expectResult, buf);
// not using wprintf, it crashes sometimes, it doesn't work for short-wchar
loggf(F("%s -> ERROR. Expect "), label);