diff --git a/rpcs3/Loader/ISO.cpp b/rpcs3/Loader/ISO.cpp index b3f9ccb8cf..e46a1a6b82 100644 --- a/rpcs3/Loader/ISO.cpp +++ b/rpcs3/Loader/ISO.cpp @@ -102,24 +102,17 @@ std::optional iso_read_directory_entry(fs::file& file, bool nam } else if (names_in_ucs2) // for strings in joliet descriptor { - std::string new_file_name; - int read = 0; - const u8* raw_str = reinterpret_cast(file_name.c_str()); - while (read < file_name_length) + // characters are stored in big endian format. + std::u16string utf16; + utf16.resize(file_name_length / 2); + + const u16* raw = reinterpret_cast(file_name.data()); + for (size_t i = 0; i < utf16.size(); ++i, raw++) { - // characters are stored in big endian format. - const u16 upper = raw_str[read]; - const u8 lower = raw_str[read + 1]; - - const u16 code_point = (upper << 8) + lower; - - std::wstring_convert, char16_t> convert; - new_file_name += convert.to_bytes(code_point); - - read += 2; + utf16[i] = *reinterpret_cast*>(raw); } - file_name = new_file_name; + file_name = utf16_to_utf8(utf16); } if (file_name.ends_with(";1"))