return _encoded_str; // If the string is ASCII then just return the memory if (_character_size == sizeof(char)) { _encoded_str = (_is_alloc) ? reinterpret_cast<char *>(_mem.alloc) : reinterpret_cast<char *>(_mem.local); return _encoded_str; } const auto rune_str = (_is_alloc) ? reinterpret_cast<rune_t *>(_mem.alloc) : reinterpret_cast<rune_t *>(_mem.local); const auto str_len = (_length * _character_size) + 1; // Plus 1 for a null terminator auto encoded_str_local = alloc_memory<char>(str_len); auto s = reinterpret_cast<uint8_t *>(encoded_str_local); for (auto i = word_t{ 0 }; i < _length; ++i) { auto curr_rune = rune_str[i]; s = utf8::encode(curr_rune, s); } // Ensure the final value is null. *s = 0; _encoded_str = encoded_str_local; return _encoded_str; }}Lines 501–527 of 527. Previous lines
return _encoded_str; // If the string is ASCII then just return the memory if (_character_size == sizeof(char)) { _encoded_str = (_is_alloc) ? reinterpret_cast<char *>(_mem.alloc) : reinterpret_cast<char *>(_mem.local); return _encoded_str; } const auto rune_str = (_is_alloc) ? reinterpret_cast<rune_t *>(_mem.alloc) : reinterpret_cast<rune_t *>(_mem.local); const auto str_len = (_length * _character_size) + 1; // Plus 1 for a null terminator auto encoded_str_local = alloc_memory<char>(str_len); auto s = reinterpret_cast<uint8_t *>(encoded_str_local); for (auto i = word_t{ 0 }; i < _length; ++i) { auto curr_rune = rune_str[i]; s = utf8::encode(curr_rune, s); } // Ensure the final value is null. *s = 0; _encoded_str = encoded_str_local; return _encoded_str; } }