Added enum 'DEFAULT' to 'IfcCharacterDecoder::ConversionMode': using default converter as system default codepage.

This commit is contained in:
Jang Myeongho
2012-06-27 04:22:51 +00:00
parent 4975de6d74
commit 1aa3a52b72
2 changed files with 28 additions and 15 deletions
+24 -11
View File
@@ -87,20 +87,30 @@ void IfcCharacterDecoder::addChar(std::stringstream& s,const UChar32& ch) {
s.put(substitution_character); s.put(substitution_character);
#endif #endif
} }
#include <iostream>
IfcCharacterDecoder::IfcCharacterDecoder(IfcParse::File* f) { IfcCharacterDecoder::IfcCharacterDecoder(IfcParse::File* f) {
file = f; file = f;
#ifdef HAVE_ICU #ifdef HAVE_ICU
if ( ! destination && mode == UTF8 ) { if (destination != nullptr) {
destination = ucnv_open("utf-8", &status); ucnv_close(destination);
} else if ( ! destination && mode == LATIN ) { }
destination = ucnv_open("iso-8859-1", &status); 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 #endif
} }
IfcCharacterDecoder::~IfcCharacterDecoder() { IfcCharacterDecoder::~IfcCharacterDecoder() {
#ifdef HAVE_ICU #ifdef HAVE_ICU
if ( destination ) ucnv_close(destination); if ( destination ) ucnv_close(destination);
if ( converter ) ucnv_close(converter); if ( converter ) ucnv_close(converter);
destination = nullptr;
converter = nullptr;
#endif #endif
} }
IfcCharacterDecoder::operator std::string() { IfcCharacterDecoder::operator std::string() {
@@ -248,7 +258,10 @@ UConverter* IfcCharacterDecoder::destination = 0;
UConverter* IfcCharacterDecoder::converter = 0; UConverter* IfcCharacterDecoder::converter = 0;
int IfcCharacterDecoder::previous_codepage = -1; int IfcCharacterDecoder::previous_codepage = -1;
UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR; UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR;
IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON;
#else
char IfcCharacterDecoder::substitution_character = '_';
#endif #endif
//#ifdef HAVE_ICU
IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON;
//#else
char IfcCharacterDecoder::substitution_character = '_';
//#endif
+4 -4
View File
@@ -51,12 +51,12 @@ namespace IfcParse {
#endif #endif
void addChar(std::stringstream& s,const UChar32& ch); void addChar(std::stringstream& s,const UChar32& ch);
public: public:
#ifdef HAVE_ICU //#ifdef HAVE_ICU
enum ConversionMode {UTF8,LATIN,JSON,PYTHON}; enum ConversionMode {DEFAULT,UTF8,LATIN,JSON,PYTHON};
static ConversionMode mode; static ConversionMode mode;
#else //#else
static char substitution_character; static char substitution_character;
#endif //#endif
IfcCharacterDecoder(IfcParse::File* file); IfcCharacterDecoder(IfcParse::File* file);
~IfcCharacterDecoder(); ~IfcCharacterDecoder();
void dryRun(); void dryRun();