summaryrefslogtreecommitdiff
path: root/libutils/Unicode.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2020-10-26 13:14:47 -0700
committerElliott Hughes <enh@google.com>2020-10-26 13:14:47 -0700
commit939e43e66ec86af7ee7a49900be084c4acd232a2 (patch)
treefe38bdc20679739b22ab61fc3ea5331aedf31795 /libutils/Unicode.cpp
parent7d55df2895344dd10d53b91f41da465b51acf77d (diff)
Remove unused utf8_length().
Test: treehugger Change-Id: Idcebc4ae1dcad102873d50f199f5e8745e589da4
Diffstat (limited to 'libutils/Unicode.cpp')
-rw-r--r--libutils/Unicode.cpp43
1 files changed, 0 insertions, 43 deletions
diff --git a/libutils/Unicode.cpp b/libutils/Unicode.cpp
index b6e457b04..843a81afb 100644
--- a/libutils/Unicode.cpp
+++ b/libutils/Unicode.cpp
@@ -359,49 +359,6 @@ void utf16_to_utf8(const char16_t* src, size_t src_len, char* dst, size_t dst_le
// UTF-8
// --------------------------------------------------------------------------
-ssize_t utf8_length(const char *src)
-{
- const char *cur = src;
- size_t ret = 0;
- while (*cur != '\0') {
- const char first_char = *cur++;
- if ((first_char & 0x80) == 0) { // ASCII
- ret += 1;
- continue;
- }
- // (UTF-8's character must not be like 10xxxxxx,
- // but 110xxxxx, 1110xxxx, ... or 1111110x)
- if ((first_char & 0x40) == 0) {
- return -1;
- }
-
- int32_t mask, to_ignore_mask;
- size_t num_to_read = 0;
- char32_t utf32 = 0;
- for (num_to_read = 1, mask = 0x40, to_ignore_mask = 0x80;
- num_to_read < 5 && (first_char & mask);
- num_to_read++, to_ignore_mask |= mask, mask >>= 1) {
- if ((*cur & 0xC0) != 0x80) { // must be 10xxxxxx
- return -1;
- }
- // 0x3F == 00111111
- utf32 = (utf32 << 6) + (*cur++ & 0x3F);
- }
- // "first_char" must be (110xxxxx - 11110xxx)
- if (num_to_read == 5) {
- return -1;
- }
- to_ignore_mask |= mask;
- utf32 |= ((~to_ignore_mask) & first_char) << (6 * (num_to_read - 1));
- if (utf32 > kUnicodeMaxCodepoint) {
- return -1;
- }
-
- ret += num_to_read;
- }
- return ret;
-}
-
ssize_t utf16_to_utf8_length(const char16_t *src, size_t src_len)
{
if (src == nullptr || src_len == 0) {