std::string I18nString::std_string() const
{
std::string str;
- size_t new_size = i18n_ustring_get_length(data_);
- if (get_last_result() != I18N_ERROR_NONE) {
- FAT("i18n_ustring_copy_ua_n failed");
+ i18n_error_code_e error = I18N_ERROR_NONE;
+ int32_t new_size;
+ i18n_ustring_to_UTF8(nullptr, 0, &new_size, data_, -1, &error);
+ if ((error != I18N_ERROR_NONE) && (error != I18N_ERROR_BUFFER_OVERFLOW)) {
+ FAT("i18n_ustring_to_UTF8 failed: %s", get_error_message(error));
}
str.reserve(new_size + 1);
str.resize(new_size);
- i18n_ustring_copy_au(&str[0], data_);
- if (get_last_result() != I18N_ERROR_NONE) {
- FAT("i18n_ustring_copy_ua_n failed");
+ i18n_ustring_to_UTF8(&str[0], str.capacity(), &new_size, data_, -1, &error);
+ if (error != I18N_ERROR_NONE) {
+ FAT("i18n_ustring_to_UTF8 failed: %s", get_error_message(error));
}
return str;
}