fix UTF-16 decoding bug

This commit is contained in:
Martin Michelsen
2023-11-16 21:02:00 -08:00
parent 35f48cbd8f
commit 9cbcd09be0
2 changed files with 5 additions and 3 deletions
+4 -2
View File
@@ -154,7 +154,8 @@ PlayerDispDataBB PlayerDispDataDCPCV3::to_bb(uint8_t to_language, uint8_t from_l
bb.stats = this->stats;
bb.visual = this->visual;
bb.visual.name.encode(" 0");
bb.name.encode(this->visual.name.decode(from_language), to_language);
string decoded_name = this->visual.name.decode(from_language);
bb.name.encode(decoded_name, to_language);
bb.config = this->config;
bb.technique_levels_v1 = this->technique_levels_v1;
return bb;
@@ -164,7 +165,8 @@ PlayerDispDataDCPCV3 PlayerDispDataBB::to_dcpcv3(uint8_t to_language, uint8_t fr
PlayerDispDataDCPCV3 ret;
ret.stats = this->stats;
ret.visual = this->visual;
ret.visual.name.encode(this->name.decode(from_language), to_language);
string decoded_name = this->name.decode(from_language);
ret.visual.name.encode(decoded_name, to_language);
ret.config = this->config;
ret.technique_levels_v1 = this->technique_levels_v1;
return ret;
+1 -1
View File
@@ -406,7 +406,7 @@ struct pstring {
case TextEncoding::SJIS:
return tt_sjis_to_utf8(this->data, this->used_chars_8());
case TextEncoding::UTF16:
return tt_utf16_to_utf8(this->data, this->used_chars_16());
return tt_utf16_to_utf8(this->data, this->used_chars_16() * 2);
case TextEncoding::UTF8:
return std::string(reinterpret_cast<const char*>(&this->data[0]), this->used_chars_8());
case TextEncoding::CHALLENGE16: {