From c4f67b08b905feb0c40058a7421e0aa7a1db9c58 Mon Sep 17 00:00:00 2001 From: q66 Date: Sun, 31 Dec 2017 20:06:36 +0100 Subject: [PATCH] rename codepoint to decode --- ostd/string.hh | 4 ++-- src/string.cc | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ostd/string.hh b/ostd/string.hh index 5c3c649..9c2fe0e 100644 --- a/ostd/string.hh +++ b/ostd/string.hh @@ -715,7 +715,7 @@ namespace utf { * The string is advanced past the UTF-8 character in the front. * 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. * @@ -774,7 +774,7 @@ namespace utf { private: void advance() { - if (char32_t ret; !codepoint(p_range, ret)) { + if (char32_t ret; !decode(p_range, ret)) { /* range is unchanged */ p_current = -1; throw utf_error{"UTF-8 decoding failed"}; diff --git a/src/string.cc b/src/string.cc index 772e6b6..49ef977 100644 --- a/src/string.cc +++ b/src/string.cc @@ -11,7 +11,7 @@ namespace utf { 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 }; if (r.empty()) { return false; @@ -61,13 +61,13 @@ static inline bool codepoint_dec(string_range &r, char32_t &cret) noexcept { return true; } -bool codepoint(string_range &r, char32_t &ret) noexcept { - return codepoint_dec(r, ret); +bool decode(string_range &r, char32_t &ret) noexcept { + return u8_decode(r, ret); } std::size_t length(string_range r, string_range &cont) noexcept { 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; } cont = r;