@@ -87,20 +87,30 @@ void IfcCharacterDecoder::addChar(std::stringstream& s,const UChar32& ch) {
8787 s.put (substitution_character);
8888#endif
8989}
90+ #include < iostream>
9091IfcCharacterDecoder::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}
100108IfcCharacterDecoder::~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}
106116IfcCharacterDecoder::operator std::string () {
@@ -248,7 +258,10 @@ UConverter* IfcCharacterDecoder::destination = 0;
248258UConverter* IfcCharacterDecoder::converter = 0 ;
249259int IfcCharacterDecoder::previous_codepage = -1 ;
250260UErrorCode IfcCharacterDecoder::status = U_ZERO_ERROR;
261+ #endif
262+
263+ // #ifdef HAVE_ICU
251264IfcCharacterDecoder::ConversionMode IfcCharacterDecoder::mode = IfcCharacterDecoder::JSON;
252- #else
265+ // #else
253266char IfcCharacterDecoder::substitution_character = ' _' ;
254- #endif
267+ // #endif
0 commit comments