From 9658fc0823f70ebc75ad93713ac2ac7aec6619cd Mon Sep 17 00:00:00 2001 From: Elliott Hughes Date: Tue, 16 Jul 2019 07:56:23 -0700 Subject: [PATCH] Remove two more unused utf32 functions. Test: builds Change-Id: I6ab2104fc6836e9edb772e8368199e6171e9d87a --- libutils/Unicode.cpp | 42 -------------------------------- libutils/include/utils/Unicode.h | 12 --------- 2 files changed, 54 deletions(-) diff --git a/libutils/Unicode.cpp b/libutils/Unicode.cpp index 24a745ac5..b08e061c0 100644 --- a/libutils/Unicode.cpp +++ b/libutils/Unicode.cpp @@ -452,48 +452,6 @@ static inline void utf8_shift_and_mask(uint32_t* codePoint, const uint8_t byte) *codePoint |= 0x3F & byte; } -size_t utf8_to_utf32_length(const char *src, size_t src_len) -{ - if (src == nullptr || src_len == 0) { - return 0; - } - size_t ret = 0; - const char* cur; - const char* end; - size_t num_to_skip; - for (cur = src, end = src + src_len, num_to_skip = 1; - cur < end; - cur += num_to_skip, ret++) { - const char first_char = *cur; - num_to_skip = 1; - if ((first_char & 0x80) == 0) { // ASCII - continue; - } - int32_t mask; - - for (mask = 0x40; (first_char & mask); num_to_skip++, mask >>= 1) { - } - } - return ret; -} - -void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst) -{ - if (src == nullptr || src_len == 0 || dst == nullptr) { - return; - } - - const char* cur = src; - const char* const end = src + src_len; - char32_t* cur_utf32 = dst; - while (cur < end) { - size_t num_read; - *cur_utf32++ = static_cast(utf32_at_internal(cur, &num_read)); - cur += num_read; - } - *cur_utf32 = 0; -} - static inline uint32_t utf8_to_utf32_codepoint(const uint8_t *src, size_t length) { uint32_t unicode; diff --git a/libutils/include/utils/Unicode.h b/libutils/include/utils/Unicode.h index a2aaa47ae..fc6712d9b 100644 --- a/libutils/include/utils/Unicode.h +++ b/libutils/include/utils/Unicode.h @@ -128,18 +128,6 @@ void utf16_to_utf8(const char16_t* src, size_t src_len, char* dst, size_t dst_le */ ssize_t utf8_length(const char *src); -/** - * Measure the length of a UTF-32 string. - */ -size_t utf8_to_utf32_length(const char *src, size_t src_len); - -/** - * Stores a UTF-32 string converted from "src" in "dst". "dst" must be large - * enough to store the entire converted string as measured by - * utf8_to_utf32_length plus space for a NUL terminator. - */ -void utf8_to_utf32(const char* src, size_t src_len, char32_t* dst); - /** * Returns the UTF-16 length of UTF-8 string "src". Returns -1 in case * it's invalid utf8. No buffer over-read occurs because of bound checks. Using overreadIsFatal you