From a5fd0fc48e9a82a4eb5aa3146d0216047a91dba5 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 18 May 2004 03:15:13 +0000 Subject: [PATCH] utf-8 fixes --- stepmania/src/RageUtil.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/stepmania/src/RageUtil.cpp b/stepmania/src/RageUtil.cpp index a671aeedf0..d35f697882 100644 --- a/stepmania/src/RageUtil.cpp +++ b/stepmania/src/RageUtil.cpp @@ -780,7 +780,7 @@ bool utf8_to_wchar_ec( const CString &s, unsigned &start, wchar_t &ch ) const int first_byte_mask[] = { -1, 0x7F, 0x1F, 0x0F, 0x07, 0x03, 0x01 }; - ch = s[start] & first_byte_mask[len]; + ch = wchar_t(s[start] & first_byte_mask[len]); for( int i = 1; i < len; ++i ) { @@ -792,7 +792,7 @@ bool utf8_to_wchar_ec( const CString &s, unsigned &start, wchar_t &ch ) return false; } - int byte = s[start+i]; + char byte = s[start+i]; if( !is_utf8_continuation_byte(byte) ) { /* We expected a continuation byte, but didn't get one. Return error, and point @@ -930,10 +930,7 @@ void utf8_sanitize( CString &s ) { wchar_t ch; if( !utf8_to_wchar_ec( s, start, ch ) ) - { - ret += INVALID_CHAR; - continue; - } + ch = INVALID_CHAR; wchar_to_utf8( ch, ret ); }