mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-25 17:57:02 +00:00
fix small issue in character decoding
This commit is contained in:
@@ -71,10 +71,13 @@ using namespace IfcParse;
|
|||||||
void IfcCharacterDecoder::addChar(std::stringstream& s,const UChar32& ch) {
|
void IfcCharacterDecoder::addChar(std::stringstream& s,const UChar32& ch) {
|
||||||
#ifdef HAVE_ICU
|
#ifdef HAVE_ICU
|
||||||
if ( destination ) {
|
if ( destination ) {
|
||||||
char* extraction_buffer = new char[4];
|
/* Note: The extraction buffer is of size 5, because in the UTF-8 encoding the
|
||||||
UnicodeString(ch).extract(extraction_buffer,4,destination,status);
|
maximum length in bytes is 4. We add 1 for the NUL character. In other encodings
|
||||||
|
the length could be higher, but we have not taken that into account. */
|
||||||
|
char extraction_buffer[5] = {};
|
||||||
|
UnicodeString(ch).extract(extraction_buffer,5,destination,status);
|
||||||
|
extraction_buffer[4] = '\0';
|
||||||
s << extraction_buffer;
|
s << extraction_buffer;
|
||||||
delete extraction_buffer;
|
|
||||||
} else {
|
} else {
|
||||||
std::stringstream s2;
|
std::stringstream s2;
|
||||||
s2 << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (int) ch;
|
s2 << "\\u" << std::hex << std::setw(4) << std::setfill('0') << (int) ch;
|
||||||
@@ -174,6 +177,8 @@ IfcCharacterDecoder::operator std::string() {
|
|||||||
throw IfcException("Invalid character encountered");
|
throw IfcException("Invalid character encountered");
|
||||||
} else {
|
} else {
|
||||||
parse_state = hex = hex_count = 0;
|
parse_state = hex = hex_count = 0;
|
||||||
|
// NOTE: this is in fact wrong, this ought to be the representation of the character.
|
||||||
|
// In UTF-8 this is the same, but we should not rely on that.
|
||||||
s.put(current_char);
|
s.put(current_char);
|
||||||
}
|
}
|
||||||
file->Inc();
|
file->Inc();
|
||||||
|
|||||||
Reference in New Issue
Block a user