From 8a212c3b6cb5100d750fb3025e79af64e4ed86e4 Mon Sep 17 00:00:00 2001 From: Einar Johan Trøan Sømåen Date: Fri, 31 Aug 2012 17:29:16 +0200 Subject: WINTERMUTE: Add namespacing to the UTF-conversion code --- engines/wintermute/utils/convert_utf.cpp | 9 +++-- engines/wintermute/utils/convert_utf.h | 61 ++++++++++++++++---------------- 2 files changed, 36 insertions(+), 34 deletions(-) (limited to 'engines') diff --git a/engines/wintermute/utils/convert_utf.cpp b/engines/wintermute/utils/convert_utf.cpp index db0c0fa9f9..7ebc011d01 100644 --- a/engines/wintermute/utils/convert_utf.cpp +++ b/engines/wintermute/utils/convert_utf.cpp @@ -41,9 +41,11 @@ #include "engines/wintermute/utils/convert_utf.h" #ifdef CVTUTF_DEBUG -#include +#include "common/textconsole.h" #endif +namespace Wintermute { + static const int halfShift = 10; /* used for shifting by 10 bits */ static const UTF32 halfBase = 0x0010000UL; @@ -158,8 +160,7 @@ ConversionResult ConvertUTF16toUTF32( *targetStart = target; #ifdef CVTUTF_DEBUG if (result == sourceIllegal) { - fprintf(stderr, "ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); - fflush(stderr); + warning("ConvertUTF16toUTF32 illegal seq 0x%04x,%04x\n", ch, ch2); } #endif return result; @@ -610,3 +611,5 @@ ConversionResult ConvertUTF8toUTF32( similarly unrolled loops. --------------------------------------------------------------------- */ + +} // End of namespace Wintermute diff --git a/engines/wintermute/utils/convert_utf.h b/engines/wintermute/utils/convert_utf.h index 03a8bb2bae..171d86343a 100644 --- a/engines/wintermute/utils/convert_utf.h +++ b/engines/wintermute/utils/convert_utf.h @@ -20,6 +20,9 @@ * remains attached. */ +// NOTE: Modifications have been made to the code for inclusion +// into ScummVM. + /* --------------------------------------------------------------------- Conversions between UTF32, UTF-16, and UTF-8. Header file. @@ -86,11 +89,14 @@ All should be unsigned values to avoid sign extension during bit mask & shift operations. ------------------------------------------------------------------------ */ +#include "common/system.h" + +namespace Wintermute { -typedef unsigned long UTF32; /* at least 32 bits */ -typedef unsigned short UTF16; /* at least 16 bits */ -typedef unsigned char UTF8; /* typically 8 bits */ -typedef unsigned char Boolean; /* 0 or 1 */ +typedef uint32 UTF32; /* at least 32 bits */ +typedef uint16 UTF16; /* at least 16 bits */ +typedef uint8 UTF8; /* typically 8 bits */ +typedef uint8 Boolean; /* 0 or 1 */ /* Some fundamental constants */ #define UNI_REPLACEMENT_CHAR (UTF32)0x0000FFFD @@ -111,39 +117,32 @@ typedef enum { lenientConversion } ConversionFlags; -/* This is for C++ and does no harm in C */ -#ifdef __cplusplus -extern "C" { -#endif - - ConversionResult ConvertUTF8toUTF16( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF8toUTF16( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); - ConversionResult ConvertUTF16toUTF8( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF16toUTF8( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); - ConversionResult ConvertUTF8toUTF32( - const UTF8 **sourceStart, const UTF8 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF8toUTF32( + const UTF8 **sourceStart, const UTF8 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); - ConversionResult ConvertUTF32toUTF8( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF32toUTF8( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF8 **targetStart, UTF8 *targetEnd, ConversionFlags flags); - ConversionResult ConvertUTF16toUTF32( - const UTF16 **sourceStart, const UTF16 *sourceEnd, - UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF16toUTF32( + const UTF16 **sourceStart, const UTF16 *sourceEnd, + UTF32 **targetStart, UTF32 *targetEnd, ConversionFlags flags); - ConversionResult ConvertUTF32toUTF16( - const UTF32 **sourceStart, const UTF32 *sourceEnd, - UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); +ConversionResult ConvertUTF32toUTF16( + const UTF32 **sourceStart, const UTF32 *sourceEnd, + UTF16 **targetStart, UTF16 *targetEnd, ConversionFlags flags); - Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); +Boolean isLegalUTF8Sequence(const UTF8 *source, const UTF8 *sourceEnd); -#ifdef __cplusplus -} -#endif +} // End of namespace Wintermute /* --------------------------------------------------------------------- */ -- cgit v1.2.3