rename codepoint to decode
parent
b350eced7e
commit
c4f67b08b9
|
@ -715,7 +715,7 @@ namespace utf {
|
||||||
* The string is advanced past the UTF-8 character in the front.
|
* The string is advanced past the UTF-8 character in the front.
|
||||||
* If the decoding fails, `false` is returned, otherwise it's `true`.
|
* If the decoding fails, `false` is returned, otherwise it's `true`.
|
||||||
*/
|
*/
|
||||||
bool codepoint(string_range &r, char32_t &ret) noexcept;
|
bool decode(string_range &r, char32_t &ret) noexcept;
|
||||||
|
|
||||||
/* @brief Get the number of Unicode code points in a string.
|
/* @brief Get the number of Unicode code points in a string.
|
||||||
*
|
*
|
||||||
|
@ -774,7 +774,7 @@ namespace utf {
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void advance() {
|
void advance() {
|
||||||
if (char32_t ret; !codepoint(p_range, ret)) {
|
if (char32_t ret; !decode(p_range, ret)) {
|
||||||
/* range is unchanged */
|
/* range is unchanged */
|
||||||
p_current = -1;
|
p_current = -1;
|
||||||
throw utf_error{"UTF-8 decoding failed"};
|
throw utf_error{"UTF-8 decoding failed"};
|
||||||
|
|
|
@ -11,7 +11,7 @@ namespace utf {
|
||||||
|
|
||||||
constexpr std::uint32_t MaxCodepoint = 0x10FFFF;
|
constexpr std::uint32_t MaxCodepoint = 0x10FFFF;
|
||||||
|
|
||||||
static inline bool codepoint_dec(string_range &r, char32_t &cret) noexcept {
|
static inline bool u8_decode(string_range &r, char32_t &cret) noexcept {
|
||||||
static const std::uint32_t ulim[] = { 0xFF, 0x7F, 0x7FF, 0xFFFF };
|
static const std::uint32_t ulim[] = { 0xFF, 0x7F, 0x7FF, 0xFFFF };
|
||||||
if (r.empty()) {
|
if (r.empty()) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -61,13 +61,13 @@ static inline bool codepoint_dec(string_range &r, char32_t &cret) noexcept {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool codepoint(string_range &r, char32_t &ret) noexcept {
|
bool decode(string_range &r, char32_t &ret) noexcept {
|
||||||
return codepoint_dec(r, ret);
|
return u8_decode(r, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t length(string_range r, string_range &cont) noexcept {
|
std::size_t length(string_range r, string_range &cont) noexcept {
|
||||||
std::size_t ret = 0;
|
std::size_t ret = 0;
|
||||||
for (char32_t ch = U'\0'; codepoint_dec(r, ch); ++ret) {
|
for (char32_t ch = U'\0'; u8_decode(r, ch); ++ret) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
cont = r;
|
cont = r;
|
||||||
|
|
Loading…
Reference in New Issue