From 1aa3a52b724d274a22eb8a9729d38a4843a1fca4 Mon Sep 17 00:00:00 2001 From: Jang Myeongho Date: Wed, 27 Jun 2012 04:22:51 +0000 Subject: [PATCH] Added enum 'DEFAULT' to 'IfcCharacterDecoder::ConversionMode': using default converter as system default codepage. --- src/ifcparse/IfcCharacterDecoder.cpp | 35 +++++++++++++++++++--------- src/ifcparse/IfcCharacterDecoder.h | 8 +++---- 2 files changed, 28 insertions(+), 15 deletions(-) diff --git a/src/ifcparse/IfcCharacterDecoder.cpp b/src/ifcparse/IfcCharacterDecoder.cpp index 3069bd9571..186a07d3fe 100644 --- a/src/ifcparse/IfcCharacterDecoder.cpp +++ b/src/ifcparse/IfcCharacterDecoder.cpp @@ -87,20 +87,30 @@ void IfcCharacterDecoder::addChar(std::stringstream& s,const UChar32& ch) { s.put(substitution_character); #endif } +#include IfcCharacterDecoder::IfcCharacterDecoder(IfcParse::File* f) { - file = f; + file = f; #ifdef HAVE_ICU - if ( ! destination && mode == UTF8 ) { - destination = ucnv_open("utf-8", &status); - } else if ( ! destination && mode == LATIN ) { - destination = ucnv_open("iso-8859-1", &status); - } + if (destination != nullptr) { + ucnv_close(destination); + } + destination = nullptr; + + if (mode == DEFAULT) { + destination = ucnv_open(nullptr, &status); + } else if (mode == UTF8) { + destination = ucnv_open("utf-8", &status); + } else if (mode == LATIN) { + destination = ucnv_open("iso-8859-1", &status); + } #endif } IfcCharacterDecoder::~IfcCharacterDecoder() { #ifdef HAVE_ICU - if ( destination ) ucnv_close(destination); - if ( converter ) ucnv_close(converter); + if ( destination ) ucnv_close(destination); + if ( converter ) ucnv_close(converter); + destination = nullptr; + converter = nullptr; #endif } IfcCharacterDecoder::operator std::string() { @@ -248,7 +258,10 @@ UConverter* IfcCharacterDecoder::destination = 0; UConverter* IfcCharacterDecoder::converter = 0; int IfcCharacterDecoder::previous_codepage = -1; UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR; -IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON; -#else -char IfcCharacterDecoder::substitution_character = '_'; #endif + +//#ifdef HAVE_ICU +IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON; +//#else +char IfcCharacterDecoder::substitution_character = '_'; +//#endif diff --git a/src/ifcparse/IfcCharacterDecoder.h b/src/ifcparse/IfcCharacterDecoder.h index a502926e27..4348cfc391 100644 --- a/src/ifcparse/IfcCharacterDecoder.h +++ b/src/ifcparse/IfcCharacterDecoder.h @@ -51,12 +51,12 @@ namespace IfcParse { #endif void addChar(std::stringstream& s,const UChar32& ch); public: -#ifdef HAVE_ICU - enum ConversionMode {UTF8,LATIN,JSON,PYTHON}; +//#ifdef HAVE_ICU + enum ConversionMode {DEFAULT,UTF8,LATIN,JSON,PYTHON}; static ConversionMode mode; -#else +//#else static char substitution_character; -#endif +//#endif IfcCharacterDecoder(IfcParse::File* file); ~IfcCharacterDecoder(); void dryRun();