diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index 972be6b0ee..ce4816ba4e 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -1031,6 +1031,14 @@ bool utf8_is_valid( const CString &s ) return true; } +/* Windows tends to drop garbage BOM characters at the start of UTF-8 text files. + * Remove them. */ +void utf8_remove_bom( CString &sLine ) +{ + if( !sLine.compare(0, 3, "\xef\xbb\xbf") ) + sLine.erase(0, 3); +} + const wchar_t INVALID_CHAR = 0xFFFD; /* U+FFFD REPLACEMENT CHARACTER */ wstring CStringToWstring( const CString &s ) diff --git a/stepmania/src/RageUtil.h b/stepmania/src/RageUtil.h index eaa1fcdd7a..ed055f3a9d 100644 --- a/stepmania/src/RageUtil.h +++ b/stepmania/src/RageUtil.h @@ -214,6 +214,7 @@ bool utf8_to_wchar_ec( const CString &s, unsigned &start, wchar_t &ch ); void wchar_to_utf8( wchar_t ch, CString &out ); wchar_t utf8_get_char( const CString &s ); bool utf8_is_valid( const CString &s ); +void utf8_remove_bom( CString &s ); CString WStringToCString(const wstring &str); CString WcharToUTF8( wchar_t c );