Skip to content

Commit 1aa3a52

Browse files
author
Jang Myeongho
committed
Added enum 'DEFAULT' to 'IfcCharacterDecoder::ConversionMode': using default converter as system default codepage.
1 parent 4975de6 commit 1aa3a52

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

src/ifcparse/IfcCharacterDecoder.cpp

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -87,20 +87,30 @@ void IfcCharacterDecoder::addChar(std::stringstream& s,const UChar32& ch) {
8787
s.put(substitution_character);
8888
#endif
8989
}
90+
#include <iostream>
9091
IfcCharacterDecoder::IfcCharacterDecoder(IfcParse::File* f) {
91-
file = f;
92+
file = f;
9293
#ifdef HAVE_ICU
93-
if ( ! destination && mode == UTF8 ) {
94-
destination = ucnv_open("utf-8", &status);
95-
} else if ( ! destination && mode == LATIN ) {
96-
destination = ucnv_open("iso-8859-1", &status);
97-
}
94+
if (destination != nullptr) {
95+
ucnv_close(destination);
96+
}
97+
destination = nullptr;
98+
99+
if (mode == DEFAULT) {
100+
destination = ucnv_open(nullptr, &status);
101+
} else if (mode == UTF8) {
102+
destination = ucnv_open("utf-8", &status);
103+
} else if (mode == LATIN) {
104+
destination = ucnv_open("iso-8859-1", &status);
105+
}
98106
#endif
99107
}
100108
IfcCharacterDecoder::~IfcCharacterDecoder() {
101109
#ifdef HAVE_ICU
102-
if ( destination ) ucnv_close(destination);
103-
if ( converter ) ucnv_close(converter);
110+
if ( destination ) ucnv_close(destination);
111+
if ( converter ) ucnv_close(converter);
112+
destination = nullptr;
113+
converter = nullptr;
104114
#endif
105115
}
106116
IfcCharacterDecoder::operator std::string() {
@@ -248,7 +258,10 @@ UConverter* IfcCharacterDecoder::destination = 0;
248258
UConverter* IfcCharacterDecoder::converter = 0;
249259
int IfcCharacterDecoder::previous_codepage = -1;
250260
UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR;
261+
#endif
262+
263+
//#ifdef HAVE_ICU
251264
IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON;
252-
#else
265+
//#else
253266
char IfcCharacterDecoder::substitution_character = '_';
254-
#endif
267+
//#endif

src/ifcparse/IfcCharacterDecoder.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@ namespace IfcParse {
5151
#endif
5252
void addChar(std::stringstream& s,const UChar32& ch);
5353
public:
54-
#ifdef HAVE_ICU
55-
enum ConversionMode {UTF8,LATIN,JSON,PYTHON};
54+
//#ifdef HAVE_ICU
55+
enum ConversionMode {DEFAULT,UTF8,LATIN,JSON,PYTHON};
5656
static ConversionMode mode;
57-
#else
57+
//#else
5858
static char substitution_character;
59-
#endif
59+
//#endif
6060
IfcCharacterDecoder(IfcParse::File* file);
6161
~IfcCharacterDecoder();
6262
void dryRun();

0 commit comments

Comments
 (0)