@@ -308,8 +308,10 @@ void Parser::Parse(const std::vector<unsigned char> &bytes, Chart **chart,
308308 continue ;
309309 }
310310
311- if (line.length () >= 7 && std::isdigit (line[1 ]) && std::isdigit (line[2 ]) &&
312- std::isdigit (line[3 ]) && line[6 ] == ' :' ) {
311+ if (line.length () >= 7 && std::isdigit (static_cast <unsigned char >(line[1 ])) &&
312+ std::isdigit (static_cast <unsigned char >(line[2 ])) &&
313+ std::isdigit (static_cast <unsigned char >(line[3 ])) &&
314+ line[6 ] == ' :' ) {
313315 const int measure =
314316 static_cast <int >(std::strtol (line.substr (1 , 3 ).c_str (), nullptr , 10 ));
315317 lastMeasure = std::max (lastMeasure, measure);
@@ -886,13 +888,13 @@ void Parser::ParseHeader(Chart *Chart, std::string_view cmd,
886888 }
887889 } else if (MatchHeader (cmd, " VOLWAV" )) {
888890 } else if (MatchHeader (cmd, " STAGEFILE" )) {
889- Chart->Meta .StageFile = Value;
891+ Chart->Meta .StageFile = utf8_to_path_t ( Value) ;
890892 } else if (MatchHeader (cmd, " BANNER" )) {
891- Chart->Meta .Banner = Value;
893+ Chart->Meta .Banner = utf8_to_path_t ( Value) ;
892894 } else if (MatchHeader (cmd, " BACKBMP" )) {
893- Chart->Meta .BackBmp = Value;
895+ Chart->Meta .BackBmp = utf8_to_path_t ( Value) ;
894896 } else if (MatchHeader (cmd, " PREVIEW" )) {
895- Chart->Meta .Preview = Value;
897+ Chart->Meta .Preview = utf8_to_path_t ( Value) ;
896898 } else if (MatchHeader (cmd, " WAV" )) {
897899 if (Xx.empty () || Value.empty ()) {
898900 // UE_LOG(LogTemp, Warning, TEXT("WAV command requires two arguments"));
@@ -1006,6 +1008,33 @@ inline int Parser::ParseInt(std::string_view Str, bool forceBase36) const {
10061008 // std::wcout << "ParseInt62: " << Str << " = " << result << std::endl;
10071009 return result;
10081010}
1011+ #ifdef _WIN32
1012+ std::wstring Parser::utf8_to_path_t (const std::string &input) {
1013+
1014+ // Determine the size of the buffer needed
1015+ int requiredSize =
1016+ MultiByteToWideChar (65001 /* UTF8 */ , 0 , input.c_str (), -1 , NULL , 0 );
1017+
1018+ if (requiredSize <= 0 ) {
1019+ // Conversion failed, return an empty string
1020+ return std::wstring ();
1021+ }
1022+
1023+ // Create a string with the required size
1024+ std::wstring result (requiredSize, ' \0 ' );
1025+
1026+ // Perform the conversion
1027+ MultiByteToWideChar (65001 /* UTF8 */ , 0 , input.c_str (), -1 , &result[0 ],
1028+ requiredSize);
1029+
1030+ // Remove the extra null terminator added by MultiByteToWideChar
1031+ result.resize (requiredSize - 1 );
1032+
1033+ return result;
1034+ }
1035+ #else
1036+ std::string Parser::utf8_to_path_t (const std::string &input) { return input; }
1037+ #endif
10091038
10101039Parser::~Parser () = default ;
10111040} // namespace bms_parser
0 commit comments