mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2025-01-22 21:01:31 +01:00
Replace utf8Conversion by unicode_conversions.
This commit is contained in:
parent
da5dc56504
commit
7ad745cfa1
@ -64,19 +64,20 @@ then
|
||||
|
||||
set -m
|
||||
|
||||
cd "$SCRIPT_DIR"
|
||||
/usr/local/bin/qemu-system-x86_64 \
|
||||
-L "$SCRIPT_DIR" \
|
||||
-L . \
|
||||
-m 2048 \
|
||||
-cpu core2duo \
|
||||
-bios "$SCRIPT_DIR"/bios.bin-1.13.0 \
|
||||
-bios ./bios.bin-1.13.0 \
|
||||
-machine q35 \
|
||||
-device VGA,vgamem_mb=64,edid=on,xres=1024,yres=768 \
|
||||
-device ahci,id=ahi \
|
||||
-drive format=raw,id=hda,file="$SCRIPT_DIR"/disk_image_gpt.img \
|
||||
-drive format=raw,id=hda,file=./disk_image_gpt.img \
|
||||
-usb \
|
||||
-device usb-mouse,bus=usb-bus.0,port=2 \
|
||||
-device usb-kbd,bus=usb-bus.0,port=1 \
|
||||
-serial file:"$SCRIPT_DIR"/serial0_qemu_out.log \
|
||||
-serial file:./serial0_qemu_out.log \
|
||||
-gdb tcp::9000
|
||||
|
||||
|
||||
|
@ -60,7 +60,6 @@
|
||||
9A57C21A2418B9A00029A39F /* XObjArray_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08522402FE9B00E2B470 /* XObjArray_tests.cpp */; };
|
||||
9A57C21B2418B9A00029A39F /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9223302402FD1000483CBA /* main.cpp */; };
|
||||
9A57C21D2418B9A00029A39F /* XStringWArray.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08472402FE9300E2B470 /* XStringWArray.cpp */; };
|
||||
9A57C21F2418B9A00029A39F /* utf8Conversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */; };
|
||||
9A57C2202418B9A00029A39F /* panic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC780A32417DD2F005CDD5C /* panic.cpp */; };
|
||||
9A57C2212418B9A00029A39F /* XStringW.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08482402FE9300E2B470 /* XStringW.cpp */; };
|
||||
9A57C2222418B9A00029A39F /* all_tests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A0B08512402FE9B00E2B470 /* all_tests.cpp */; };
|
||||
@ -78,14 +77,12 @@
|
||||
9A57C269241A799B0029A39F /* XString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C267241A799B0029A39F /* XString.cpp */; };
|
||||
9A57C26A241A799B0029A39F /* XString.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A57C267241A799B0029A39F /* XString.cpp */; };
|
||||
9A9223312402FD1000483CBA /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9223302402FD1000483CBA /* main.cpp */; };
|
||||
9A9AEB8D243F73CE00FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */; };
|
||||
9A9AEB8E243F752C00FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */; };
|
||||
9A9AEB8F243F752C00FBD7D8 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */; };
|
||||
9AA0458A2425F94D000D6970 /* printf_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA045892425F94D000D6970 /* printf_lite-test.cpp */; };
|
||||
9AA0458B2425F94D000D6970 /* printf_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA045892425F94D000D6970 /* printf_lite-test.cpp */; };
|
||||
9AA0458C2425F94D000D6970 /* printf_lite-test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA045892425F94D000D6970 /* printf_lite-test.cpp */; };
|
||||
9AA0458F2425F979000D6970 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA0458D2425F979000D6970 /* unicode_conversions.cpp */; };
|
||||
9AA045902425F979000D6970 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA0458D2425F979000D6970 /* unicode_conversions.cpp */; };
|
||||
9AA045912425F979000D6970 /* unicode_conversions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA0458D2425F979000D6970 /* unicode_conversions.cpp */; };
|
||||
9AA05BB7240FC78D008EA4F8 /* utf8Conversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */; };
|
||||
9AA05BB8240FC78D008EA4F8 /* utf8Conversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */; };
|
||||
9AC780AE2417DD2F005CDD5C /* panic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC780A32417DD2F005CDD5C /* panic.cpp */; };
|
||||
9AC780AF2417DD2F005CDD5C /* panic.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9AC780A32417DD2F005CDD5C /* panic.cpp */; };
|
||||
9ACAB117242623EE00BDB3CF /* printf_lite.c in Sources */ = {isa = PBXBuildFile; fileRef = 9ACAB116242623EE00BDB3CF /* printf_lite.c */; };
|
||||
@ -174,14 +171,12 @@
|
||||
9A92232D2402FD1000483CBA /* cpp_tests UTF16 signed char */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "cpp_tests UTF16 signed char"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
9A9223302402FD1000483CBA /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
|
||||
9A92234D2402FD9500483CBA /* Platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Platform.h; sourceTree = "<group>"; };
|
||||
9A9AEB8B243F73CE00FBD7D8 /* unicode_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unicode_conversions.h; sourceTree = "<group>"; };
|
||||
9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unicode_conversions.cpp; sourceTree = "<group>"; };
|
||||
9AA045732425D200000D6970 /* IO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IO.h; sourceTree = "<group>"; };
|
||||
9AA045742425D200000D6970 /* IO.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = IO.cpp; sourceTree = "<group>"; };
|
||||
9AA045882425F94D000D6970 /* printf_lite-test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "printf_lite-test.h"; sourceTree = "<group>"; };
|
||||
9AA045892425F94D000D6970 /* printf_lite-test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = "printf_lite-test.cpp"; sourceTree = "<group>"; };
|
||||
9AA0458D2425F979000D6970 /* unicode_conversions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = unicode_conversions.cpp; sourceTree = "<group>"; };
|
||||
9AA0458E2425F979000D6970 /* unicode_conversions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = unicode_conversions.h; sourceTree = "<group>"; };
|
||||
9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = utf8Conversion.cpp; sourceTree = "<group>"; };
|
||||
9AA05BB9240FC796008EA4F8 /* utf8Conversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = utf8Conversion.h; sourceTree = "<group>"; };
|
||||
9AC780A32417DD2F005CDD5C /* panic.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = panic.cpp; sourceTree = "<group>"; };
|
||||
9AC780A62417DD2F005CDD5C /* panic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = panic.h; sourceTree = "<group>"; };
|
||||
9ACAB116242623EE00BDB3CF /* printf_lite.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = printf_lite.c; sourceTree = "<group>"; };
|
||||
@ -228,8 +223,8 @@
|
||||
9A0B08432402FE9300E2B470 /* cpp_foundation */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
9AA05BB6240FC78D008EA4F8 /* utf8Conversion.cpp */,
|
||||
9AA05BB9240FC796008EA4F8 /* utf8Conversion.h */,
|
||||
9A9AEB8C243F73CE00FBD7D8 /* unicode_conversions.cpp */,
|
||||
9A9AEB8B243F73CE00FBD7D8 /* unicode_conversions.h */,
|
||||
9A0B084A2402FE9300E2B470 /* XArray.h */,
|
||||
9A0B084B2402FE9300E2B470 /* XObjArray.h */,
|
||||
9A57C267241A799B0029A39F /* XString.cpp */,
|
||||
@ -273,8 +268,6 @@
|
||||
9A28CD14241BACBB00F3D247 /* strlen_test.h */,
|
||||
9A28CD05241B8DD400F3D247 /* strncmp_test.cpp */,
|
||||
9A28CD08241B8DD400F3D247 /* strncmp_test.h */,
|
||||
9AA0458D2425F979000D6970 /* unicode_conversions.cpp */,
|
||||
9AA0458E2425F979000D6970 /* unicode_conversions.h */,
|
||||
9A0B08532402FE9B00E2B470 /* XArray_tests.cpp */,
|
||||
9A0B084E2402FE9B00E2B470 /* XArray_tests.h */,
|
||||
9A0B08522402FE9B00E2B470 /* XObjArray_tests.cpp */,
|
||||
@ -485,14 +478,13 @@
|
||||
9A0B08772403B08400E2B470 /* XStringWArray.cpp in Sources */,
|
||||
9A28CD0D241B8DD400F3D247 /* strcmp_test.cpp in Sources */,
|
||||
9A28CD0A241B8DD400F3D247 /* strncmp_test.cpp in Sources */,
|
||||
9AA05BB8240FC78D008EA4F8 /* utf8Conversion.cpp in Sources */,
|
||||
9AC780AF2417DD2F005CDD5C /* panic.cpp in Sources */,
|
||||
9A0B08792403B08400E2B470 /* XStringW.cpp in Sources */,
|
||||
9A0B087A2403B08400E2B470 /* all_tests.cpp in Sources */,
|
||||
9A9AEB8E243F752C00FBD7D8 /* unicode_conversions.cpp in Sources */,
|
||||
9A0B087B2403B08400E2B470 /* global_test.cpp in Sources */,
|
||||
9A0B087C2403B08400E2B470 /* XToolsCommon.cpp in Sources */,
|
||||
9ACAB1192426255C00BDB3CF /* printf_lite.c in Sources */,
|
||||
9AA045902425F979000D6970 /* unicode_conversions.cpp in Sources */,
|
||||
9A0B087D2403B08400E2B470 /* XStringWArray_test.cpp in Sources */,
|
||||
9A28CD11241B9EF800F3D247 /* strcmp.cpp in Sources */,
|
||||
9A4185C12439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
|
||||
@ -520,14 +512,13 @@
|
||||
9A57C21D2418B9A00029A39F /* XStringWArray.cpp in Sources */,
|
||||
9A28CD0E241B8DD400F3D247 /* strcmp_test.cpp in Sources */,
|
||||
9A28CD0B241B8DD400F3D247 /* strncmp_test.cpp in Sources */,
|
||||
9A57C21F2418B9A00029A39F /* utf8Conversion.cpp in Sources */,
|
||||
9A57C2202418B9A00029A39F /* panic.cpp in Sources */,
|
||||
9A57C2212418B9A00029A39F /* XStringW.cpp in Sources */,
|
||||
9A57C2222418B9A00029A39F /* all_tests.cpp in Sources */,
|
||||
9A9AEB8F243F752C00FBD7D8 /* unicode_conversions.cpp in Sources */,
|
||||
9A57C2232418B9A00029A39F /* global_test.cpp in Sources */,
|
||||
9A57C2242418B9A00029A39F /* XToolsCommon.cpp in Sources */,
|
||||
9ACAB11A2426255C00BDB3CF /* printf_lite.c in Sources */,
|
||||
9AA045912425F979000D6970 /* unicode_conversions.cpp in Sources */,
|
||||
9A57C2252418B9A00029A39F /* XStringWArray_test.cpp in Sources */,
|
||||
9A28CD12241B9EF800F3D247 /* strcmp.cpp in Sources */,
|
||||
9A4185C22439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
|
||||
@ -554,7 +545,6 @@
|
||||
9A0B08562402FF7700E2B470 /* XStringWArray.cpp in Sources */,
|
||||
9A28CD0C241B8DD400F3D247 /* strcmp_test.cpp in Sources */,
|
||||
9A28CD09241B8DD400F3D247 /* strncmp_test.cpp in Sources */,
|
||||
9AA05BB7240FC78D008EA4F8 /* utf8Conversion.cpp in Sources */,
|
||||
9AF41576242CBE7600D2644C /* poolprint-test.cpp in Sources */,
|
||||
9AC780AE2417DD2F005CDD5C /* panic.cpp in Sources */,
|
||||
9A0B085F240308E400E2B470 /* XStringW.cpp in Sources */,
|
||||
@ -563,8 +553,8 @@
|
||||
9A4185B12439E4D600BEAFB8 /* LoadOptions_test.cpp in Sources */,
|
||||
9A0B08572402FF7A00E2B470 /* XToolsCommon.cpp in Sources */,
|
||||
9ACAB117242623EE00BDB3CF /* printf_lite.c in Sources */,
|
||||
9AA0458F2425F979000D6970 /* unicode_conversions.cpp in Sources */,
|
||||
9A0B08582402FF7F00E2B470 /* XStringWArray_test.cpp in Sources */,
|
||||
9A9AEB8D243F73CE00FBD7D8 /* unicode_conversions.cpp in Sources */,
|
||||
9A4185C02439F73A00BEAFB8 /* XStringArray.cpp in Sources */,
|
||||
9A28CD10241B9EF800F3D247 /* strcmp.cpp in Sources */,
|
||||
9A57C2152418A6EA0029A39F /* XStringWP.cpp in Sources */,
|
||||
|
@ -19,7 +19,7 @@
|
||||
#include <codecvt>
|
||||
#include <vector>
|
||||
|
||||
#include "../../../rEFIt_UEFI/cpp_foundation/utf8Conversion.h"
|
||||
#include "../../../rEFIt_UEFI/cpp_foundation/unicode_conversions.h"
|
||||
|
||||
void CpuDeadLoop(void)
|
||||
{
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <string.h>
|
||||
#include <inttypes.h>
|
||||
#include <wchar.h>
|
||||
#include "../../../rEFIt_UEFI/cpp_unit_test/unicode_conversions.h"
|
||||
#include "../../../rEFIt_UEFI/cpp_foundation/unicode_conversions.h"
|
||||
#include "posix.h"
|
||||
#include "xcode_utf16.h"
|
||||
|
||||
|
@ -119,9 +119,9 @@ const XStringW& XStringW::takeValueFrom(const wchar_t* S)
|
||||
|
||||
const XStringW& XStringW::takeValueFrom(const char* S)
|
||||
{
|
||||
xsize newLen = StrLenInWChar(S);
|
||||
xsize newLen = utf8_string_wchar_count(S);
|
||||
Init(newLen);
|
||||
utf8ToWChar(m_data, m_allocatedSize+1, S); // m_size doesn't count the NULL terminator
|
||||
wchar_string_from_utf8_string(m_data, m_allocatedSize+1, S); // m_size doesn't count the NULL terminator
|
||||
SetLength(newLen);
|
||||
return *this;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
#define __XSTRINGW_H__
|
||||
|
||||
#include "XToolsCommon.h"
|
||||
#include "utf8Conversion.h"
|
||||
#include "unicode_conversions.h"
|
||||
|
||||
#define LPATH_SEPARATOR L'\\'
|
||||
|
||||
|
@ -1,184 +0,0 @@
|
||||
//
|
||||
// utf8Conversion.hpp
|
||||
//
|
||||
// Created by jief the 24 Feb 2020.
|
||||
//
|
||||
|
||||
#include "utf8Conversion.h"
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#define uint16_t UINT16
|
||||
#define uint32_t UINT32
|
||||
#define size_t UINTN
|
||||
|
||||
|
||||
size_t StrLenInWChar(const char *s)
|
||||
{
|
||||
if ( !s ) return 0;
|
||||
size_t dst_len = 0;
|
||||
|
||||
while ( *s ) {
|
||||
char32_t c;
|
||||
if (*s & 0x80) {
|
||||
if (*(s+1) == 0) {
|
||||
// Finished in the middle of an utf8 multibyte char
|
||||
return dst_len;
|
||||
}
|
||||
if ((*(s+1) & 0xc0) != 0x80) {
|
||||
s += 1;
|
||||
continue;
|
||||
}
|
||||
if ((*s & 0xe0) == 0xe0) {
|
||||
if (*(s+2) == 0) {
|
||||
// Finished in the middle of an utf8 multibyte char
|
||||
return dst_len;
|
||||
}
|
||||
if ((*(s+2) & 0xc0) != 0x80) {
|
||||
s += 2;
|
||||
continue;
|
||||
}
|
||||
if ((*s & 0xf0) == 0xf0) {
|
||||
if (*(s+3) == 0) {
|
||||
// Finished in the middle of an utf8 multibyte char
|
||||
return dst_len;
|
||||
}
|
||||
if ((*s & 0xf8) != 0xf0 || (*(s+3) & 0xc0) != 0x80) {
|
||||
s += 3;
|
||||
continue;
|
||||
}
|
||||
/* 4-byte code */
|
||||
c = char32_t(((unsigned char)(*s) & 0x7) << 18); // & result type is int. We know it fits in 32 bits. Safe to cast to char32_t
|
||||
c |= char32_t((*(s+1) & 0x3f) << 12);
|
||||
c |= char32_t((*(s+2) & 0x3f) << 6);
|
||||
c |= *(s+3) & 0x3f;
|
||||
s += 4;
|
||||
} else {
|
||||
/* 3-byte code */
|
||||
c = char32_t((*s & 0xf) << 12);
|
||||
c |= char32_t((*(s+1) & 0x3f) << 6);
|
||||
c |= *(s+2) & 0x3f;
|
||||
s += 3;
|
||||
}
|
||||
} else {
|
||||
/* 2-byte code */
|
||||
c = char32_t((*s & 0x1f) << 6);
|
||||
c |= *(s+1) & 0x3f;
|
||||
s += 2;
|
||||
}
|
||||
} else {
|
||||
/* 1-byte code */
|
||||
c = (unsigned char)(*s); // in case we compiled with signed char
|
||||
s += 1;
|
||||
}
|
||||
#if __WCHAR_MAX__ > 0xFFFFu
|
||||
dst_len++;
|
||||
#else
|
||||
if ( c <= 0xFFFF) {
|
||||
dst_len++;
|
||||
} else {
|
||||
dst_len++;
|
||||
dst_len++;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return dst_len;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define halfBase 0x0010000UL
|
||||
#define halfMask 0x3FFUL
|
||||
#define halfShift 10 /* used for shifting by 10 bits */
|
||||
#define UNI_SUR_HIGH_START 0xD800u
|
||||
#define UNI_SUR_LOW_START 0xDC00u
|
||||
|
||||
|
||||
|
||||
size_t utf8ToWChar(wchar_t* dst, size_t dst_max_len, const char *s)
|
||||
{
|
||||
if ( dst_max_len == 0 ) return 0;
|
||||
dst_max_len -= 1;
|
||||
|
||||
size_t dst_len = 0;
|
||||
|
||||
while ( *s ) {
|
||||
char32_t c;
|
||||
if (*s & 0x80) {
|
||||
if (*(s+1) == 0) {
|
||||
// Finished in the middle of an utf8 multibyte char
|
||||
goto exit;
|
||||
}
|
||||
if ((*(s+1) & 0xc0) != 0x80) {
|
||||
s += 1;
|
||||
continue;
|
||||
}
|
||||
if ((*s & 0xe0) == 0xe0) {
|
||||
if (*(s+2) == 0) {
|
||||
// Finished in the middle of an utf8 multibyte char
|
||||
goto exit;
|
||||
}
|
||||
if ((*(s+2) & 0xc0) != 0x80) {
|
||||
s += 2;
|
||||
continue;
|
||||
}
|
||||
if ((*s & 0xf0) == 0xf0) {
|
||||
if (*(s+3) == 0) {
|
||||
// Finished in the middle of an utf8 multibyte char
|
||||
goto exit;
|
||||
}
|
||||
if ((*s & 0xf8) != 0xf0 || (*(s+3) & 0xc0) != 0x80) {
|
||||
s += 3;
|
||||
continue;
|
||||
}
|
||||
/* 4-byte code */
|
||||
c = char32_t((*s & 0x7) << 18); // & result type is int. We know it fits in 32 bits. Safe to cast to char32_t
|
||||
c |= char32_t((*(s+1) & 0x3f) << 12);
|
||||
c |= char32_t((*(s+2) & 0x3f) << 6);
|
||||
c |= *(s+3) & 0x3f;
|
||||
s += 4;
|
||||
} else {
|
||||
/* 3-byte code */
|
||||
c = char32_t((*s & 0xf) << 12);
|
||||
c |= char32_t((*(s+1) & 0x3f) << 6);
|
||||
c |= *(s+2) & 0x3f;
|
||||
s += 3;
|
||||
}
|
||||
} else {
|
||||
/* 2-byte code */
|
||||
c = char32_t((*s & 0x1f) << 6);
|
||||
c |= *(s+1) & 0x3f;
|
||||
s += 2;
|
||||
}
|
||||
} else {
|
||||
/* 1-byte code */
|
||||
c = (unsigned char)(*s); // in case we compiled with signed char
|
||||
s += 1;
|
||||
}
|
||||
#if __WCHAR_MAX__ > 0xFFFFu
|
||||
dst[dst_len++] = (wchar_t)c;
|
||||
if ( dst_len == dst_max_len ) goto exit;
|
||||
#else
|
||||
if ( c <= 0xFFFF) {
|
||||
dst[dst_len++] = (wchar_t)c;
|
||||
if ( dst_len == dst_max_len ) goto exit;
|
||||
} else {
|
||||
c -= halfBase;
|
||||
dst[dst_len++] = (wchar_t)((c >> halfShift) + UNI_SUR_HIGH_START);
|
||||
if ( dst_len == dst_max_len ) goto exit;
|
||||
dst[dst_len++] = (wchar_t)((c & halfMask) + UNI_SUR_LOW_START);
|
||||
if ( dst_len == dst_max_len ) goto exit;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
exit:
|
||||
dst[dst_len] = 0;
|
||||
return dst_len;
|
||||
}
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
//
|
||||
// utf8Conversion.hpp
|
||||
//
|
||||
// Created by jief the 24 Feb 2020.
|
||||
//
|
||||
|
||||
#ifndef utf816Conversion_hpp
|
||||
#define utf816Conversion_hpp
|
||||
|
||||
#include <posix.h>
|
||||
|
||||
UINTN StrLenInWChar(const char *src);
|
||||
UINTN utf8ToWChar(wchar_t* dst, UINTN dst_max_len, const char *s);
|
||||
|
||||
#endif /* utf816Conversion_hpp */
|
@ -1,6 +1,6 @@
|
||||
#include <Platform.h>
|
||||
#include "../cpp_foundation/XStringW.h"
|
||||
#include "../cpp_foundation/utf8Conversion.h"
|
||||
#include "../cpp_foundation/unicode_conversions.h"
|
||||
#include "global_test.h"
|
||||
|
||||
|
||||
@ -164,12 +164,17 @@ int XStringW_tests()
|
||||
|
||||
{
|
||||
XStringW utf16;
|
||||
utf16.takeValueFrom(L"Выход из подменю, обновление главного меню\n");
|
||||
utf16.takeValueFrom(L"Выход из подменю, обновление главного меню");
|
||||
for ( size_t i = 0 ; i < utf16.length() ; i++ ) {
|
||||
if ( utf16[i] != utf16.wc_str()[i] ) {
|
||||
return 100;
|
||||
}
|
||||
}
|
||||
XStringW utf16_2;
|
||||
utf16_2.takeValueFrom("Выход из подменю, обновление главного меню");
|
||||
if ( utf16 != utf16_2 ) {
|
||||
return 101;
|
||||
}
|
||||
}
|
||||
|
||||
// XStringW CommonName(L"EFI\\CLOVER\\misc\\screenshot");
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <Platform.h>
|
||||
#include "../cpp_foundation/XString.h"
|
||||
#include "../cpp_foundation/utf8Conversion.h"
|
||||
#include "../cpp_foundation/unicode_conversions.h"
|
||||
#include "global_test.h"
|
||||
|
||||
template<int m_size>
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <Platform.h>
|
||||
#include <limits.h>
|
||||
#include "unicode_conversions.h"
|
||||
#include "../cpp_foundation/unicode_conversions.h"
|
||||
#include <poolprint-test-cpp_conf.h>
|
||||
#include "poolprint-test.h"
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
#include <Platform.h>
|
||||
#include <limits.h>
|
||||
#include "unicode_conversions.h"
|
||||
#include "../cpp_foundation/unicode_conversions.h"
|
||||
#include <printf_lite-test-cpp_conf.h>
|
||||
#include "printf_lite-test.h"
|
||||
#include <printf_lite-conf.h>
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <Platform.h>
|
||||
#include "../cpp_foundation/XString.h"
|
||||
#include "../cpp_foundation/utf8Conversion.h"
|
||||
#include "../cpp_foundation/unicode_conversions.h"
|
||||
#include "global_test.h"
|
||||
|
||||
static float rndf() //expected 0..1
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <Platform.h>
|
||||
#include "../cpp_foundation/XString.h"
|
||||
#include "../cpp_foundation/utf8Conversion.h"
|
||||
#include "../cpp_foundation/unicode_conversions.h"
|
||||
#include "global_test.h"
|
||||
|
||||
//size_t clover_strlen (const char *str);
|
||||
|
@ -1,6 +1,6 @@
|
||||
#include <Platform.h>
|
||||
#include "../cpp_foundation/XString.h"
|
||||
#include "../cpp_foundation/utf8Conversion.h"
|
||||
#include "../cpp_foundation/unicode_conversions.h"
|
||||
#include "global_test.h"
|
||||
|
||||
static float rndf() //expected 0..1
|
||||
|
@ -211,8 +211,8 @@
|
||||
cpp_util/operatorNewDelete.cpp
|
||||
cpp_util/operatorNewDelete.h
|
||||
cpp_util/remove_ref.h
|
||||
cpp_foundation/utf8Conversion.cpp
|
||||
cpp_foundation/utf8Conversion.h
|
||||
cpp_foundation/unicode_conversions.cpp
|
||||
cpp_foundation/unicode_conversions.h
|
||||
cpp_foundation/XArray.h
|
||||
cpp_foundation/XObjArray.h
|
||||
cpp_foundation/XString.cpp
|
||||
@ -235,8 +235,6 @@
|
||||
cpp_unit_test/global_test.cpp
|
||||
cpp_unit_test/LoadOptions_test.cpp
|
||||
cpp_unit_test/LoadOptions_test.h
|
||||
cpp_unit_test/unicode_conversions.cpp
|
||||
cpp_unit_test/unicode_conversions.h
|
||||
cpp_unit_test/printf_lite-test.cpp
|
||||
cpp_unit_test/printf_lite-test.h
|
||||
cpp_unit_test/printf_lite-test-cpp_conf.h
|
||||
|
@ -2080,7 +2080,9 @@ RefitMain (IN EFI_HANDLE ImageHandle,
|
||||
#endif
|
||||
|
||||
construct_globals_objects(); // do this after SelfLoadedImage is initialized
|
||||
// all_tests();
|
||||
#ifdef JIEF_DEBUG
|
||||
all_tests();
|
||||
#endif
|
||||
|
||||
//dumping SETTING structure
|
||||
// if you change something in Platform.h, please uncomment and test that all offsets
|
||||
|
Loading…
Reference in New Issue
Block a user