diff options
Diffstat (limited to 'libs/litehtml/src')
-rw-r--r-- | libs/litehtml/src/background.cpp | 12 | ||||
-rw-r--r-- | libs/litehtml/src/document_container.cpp | 24 | ||||
-rw-r--r-- | libs/litehtml/src/el_before_after.cpp | 6 | ||||
-rw-r--r-- | libs/litehtml/src/num_cvt.cpp | 6 | ||||
-rw-r--r-- | libs/litehtml/src/utf8_strings.cpp | 24 |
5 files changed, 35 insertions, 37 deletions
diff --git a/libs/litehtml/src/background.cpp b/libs/litehtml/src/background.cpp index 2a3ac7b88b..b7ae75c6b6 100644 --- a/libs/litehtml/src/background.cpp +++ b/libs/litehtml/src/background.cpp @@ -786,7 +786,7 @@ bool litehtml::background_layer::gradient_base::prepare_color_points(float line_ } if(item.length.units() == css_units_percentage) { - color_points.emplace_back(item.length.val() / 100.0, item.color); + color_points.emplace_back(item.length.val() / 100.0f, item.color); } else if(item.length.units() != css_units_none) { if(line_len != 0) @@ -799,7 +799,7 @@ bool litehtml::background_layer::gradient_base::prepare_color_points(float line_ { none_units++; } - color_points.emplace_back(0, item.color); + color_points.emplace_back(0.0f, item.color); } } if(color_points.empty()) @@ -812,7 +812,7 @@ bool litehtml::background_layer::gradient_base::prepare_color_points(float line_ // Add color point with offset 0 if not exists if(color_points[0].offset != 0) { - color_points.emplace(color_points.begin(), 0, color_points[0].color); + color_points.emplace(color_points.begin(), 0.0f, color_points[0].color); } // Add color point with offset 1.0 if not exists if (color_points.back().offset < 1) @@ -823,7 +823,7 @@ bool litehtml::background_layer::gradient_base::prepare_color_points(float line_ none_units--; } else { - color_points.emplace_back(1.0, color_points.back().color); + color_points.emplace_back(1.0f, color_points.back().color); } } } else @@ -901,7 +901,7 @@ bool litehtml::background_layer::gradient_base::prepare_angle_color_points(backg { none_units++; } - color_points.emplace_back(0, item.color); + color_points.emplace_back(0.0f, item.color); } else { color_points.emplace_back(item.angle, item.color); @@ -917,7 +917,7 @@ bool litehtml::background_layer::gradient_base::prepare_angle_color_points(backg // Add color point with offset 0 if not exists if (color_points[0].offset != 0) { - color_points.emplace(color_points.begin(), 0, color_points[0].color); + color_points.emplace(color_points.begin(), 0.0f, color_points[0].color); } // Add color point with offset 1.0 if not exists if (color_points.back().offset < 360.0f) diff --git a/libs/litehtml/src/document_container.cpp b/libs/litehtml/src/document_container.cpp index 2fb601efe4..8c3aea61bd 100644 --- a/libs/litehtml/src/document_container.cpp +++ b/libs/litehtml/src/document_container.cpp @@ -3,21 +3,19 @@ void litehtml::document_container::split_text(const char* text, const std::function<void(const char*)>& on_word, const std::function<void(const char*)>& on_space) { - std::wstring str; - std::wstring str_in = (const wchar_t*)utf8_to_wchar(text); - ucode_t c; - for (size_t i = 0; i < str_in.length(); i++) + std::u32string str; + std::u32string str_in = (const char32_t*)utf8_to_utf32(text); + for (auto c : str_in) { - c = (ucode_t)str_in[i]; if (c <= ' ' && (c == ' ' || c == '\t' || c == '\n' || c == '\r' || c == '\f')) { if (!str.empty()) { - on_word(wchar_to_utf8(str.c_str())); + on_word(utf32_to_utf8(str)); str.clear(); } - str += (wchar_t)c; - on_space(wchar_to_utf8(str.c_str())); + str += c; + on_space(utf32_to_utf8(str)); str.clear(); } // CJK character range @@ -25,20 +23,20 @@ void litehtml::document_container::split_text(const char* text, const std::funct { if (!str.empty()) { - on_word(wchar_to_utf8(str.c_str())); + on_word(utf32_to_utf8(str)); str.clear(); } - str += (wchar_t)c; - on_word(wchar_to_utf8(str.c_str())); + str += c; + on_word(utf32_to_utf8(str)); str.clear(); } else { - str += (wchar_t)c; + str += c; } } if (!str.empty()) { - on_word(wchar_to_utf8(str.c_str())); + on_word(utf32_to_utf8(str)); } } diff --git a/libs/litehtml/src/el_before_after.cpp b/libs/litehtml/src/el_before_after.cpp index 39fa646cea..5bf5aae81c 100644 --- a/libs/litehtml/src/el_before_after.cpp +++ b/libs/litehtml/src/el_before_after.cpp @@ -208,8 +208,8 @@ void litehtml::el_before_after_base::add_function( const string& fnc, const stri litehtml::string litehtml::el_before_after_base::convert_escape( const char* txt ) { char* str_end; - wchar_t u_str[2]; - u_str[0] = (wchar_t) strtol(txt, &str_end, 16); + char32_t u_str[2]; + u_str[0] = (char32_t) strtol(txt, &str_end, 16); u_str[1] = 0; - return litehtml::string(litehtml_from_wchar(u_str)); + return litehtml::string(litehtml_from_utf32(u_str)); } diff --git a/libs/litehtml/src/num_cvt.cpp b/libs/litehtml/src/num_cvt.cpp index 23d594b5c9..b1d0f3b75e 100644 --- a/libs/litehtml/src/num_cvt.cpp +++ b/libs/litehtml/src/num_cvt.cpp @@ -4,7 +4,7 @@ static std::vector<char> latin_lower = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' }; static std::vector<char> latin_upper = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z' }; -static std::vector<std::wstring> greek_lower = { L"α", L"β", L"γ", L"δ", L"ε", L"ζ", L"η", L"θ", L"ι", L"κ", L"λ", L"μ", L"ν", L"ξ", L"ο", L"π", L"ρ", L"σ", L"τ", L"υ", L"φ", L"χ", L"ψ", L"ω" }; +static std::vector<std::u32string> greek_lower = { U"α", U"β", U"γ", U"δ", U"ε", U"ζ", U"η", U"θ", U"ι", U"κ", U"λ", U"μ", U"ν", U"ξ", U"ο", U"π", U"ρ", U"σ", U"τ", U"υ", U"φ", U"χ", U"ψ", U"ω" }; static litehtml::string to_mapped_alpha(int num, const std::vector<char>& map) { @@ -22,7 +22,7 @@ static litehtml::string to_mapped_alpha(int num, const std::vector<char>& map) return out; } -static litehtml::string to_mapped_alpha(int num, const std::vector<std::wstring>& map) +static litehtml::string to_mapped_alpha(int num, const std::vector<std::u32string>& map) { int dividend = num; litehtml::string out; @@ -31,7 +31,7 @@ static litehtml::string to_mapped_alpha(int num, const std::vector<std::wstring> while (dividend > 0) { modulo = (dividend - 1) % map.size(); - out = litehtml_from_wchar(map[modulo]).c_str() + out; + out = litehtml_from_utf32(map[modulo]).c_str() + out; dividend = (int)((dividend - modulo) / map.size()); } diff --git a/libs/litehtml/src/utf8_strings.cpp b/libs/litehtml/src/utf8_strings.cpp index ae74d10f1d..864a4d0147 100644 --- a/libs/litehtml/src/utf8_strings.cpp +++ b/libs/litehtml/src/utf8_strings.cpp @@ -4,22 +4,22 @@ namespace litehtml { -utf8_to_wchar::utf8_to_wchar(const char* val) +utf8_to_utf32::utf8_to_utf32(const char* val) { m_utf8 = (const byte*) val; if (!m_utf8) return; while (true) { - ucode_t wch = get_char(); + char32_t wch = get_char(); if (!wch) break; - m_str += (wchar_t)wch; + m_str += wch; } } -ucode_t utf8_to_wchar::get_char() +char32_t utf8_to_utf32::get_char() { - ucode_t b1 = getb(); + char32_t b1 = getb(); if (!b1) { @@ -37,14 +37,14 @@ ucode_t utf8_to_wchar::get_char() else if ((b1 & 0xe0) == 0xc0) { // 2-byte sequence: 00000yyyyyxxxxxx = 110yyyyy 10xxxxxx - ucode_t r = (b1 & 0x1f) << 6; + char32_t r = (b1 & 0x1f) << 6; r |= get_next_utf8(getb()); return r; } else if ((b1 & 0xf0) == 0xe0) { // 3-byte sequence: zzzzyyyyyyxxxxxx = 1110zzzz 10yyyyyy 10xxxxxx - ucode_t r = (b1 & 0x0f) << 12; + char32_t r = (b1 & 0x0f) << 12; r |= get_next_utf8(getb()) << 6; r |= get_next_utf8(getb()); return r; @@ -54,9 +54,9 @@ ucode_t utf8_to_wchar::get_char() // 4-byte sequence: 11101110wwwwzzzzyy + 110111yyyyxxxxxx // = 11110uuu 10uuzzzz 10yyyyyy 10xxxxxx // (uuuuu = wwww + 1) - int b2 = get_next_utf8(getb()); - int b3 = get_next_utf8(getb()); - int b4 = get_next_utf8(getb()); + char32_t b2 = get_next_utf8(getb()); + char32_t b3 = get_next_utf8(getb()); + char32_t b4 = get_next_utf8(getb()); return ((b1 & 7) << 18) | ((b2 & 0x3f) << 12) | ((b3 & 0x3f) << 6) | (b4 & 0x3f); } @@ -65,7 +65,7 @@ ucode_t utf8_to_wchar::get_char() return '?'; } -void append_char(string& str, int code) +void append_char(string& str, char32_t code) { if (code <= 0x7F) { @@ -95,7 +95,7 @@ void append_char(string& str, int code) } } -wchar_to_utf8::wchar_to_utf8(const std::wstring& wstr) +utf32_to_utf8::utf32_to_utf8(const std::u32string& wstr) { for (auto ch: wstr) append_char(m_str, ch); |