Confitionally select num_bytes, see #699

This commit is contained in:
Thomas Krijnen
2019-11-05 17:23:13 +01:00
parent e36357d381
commit c59c74aeed
+1 -1
View File
@@ -317,7 +317,7 @@ IfcCharacterEncoder::operator std::string() {
// Either 2 or 4 to uses \X2 or \X4 respectively.
// Currently hardcoded to 4, but \X2 might be
// sufficient for nearly all purposes.
const int num_bytes = 4;
const int num_bytes = *std::max_element(str.begin(), str.end()) > 0xffff ? 4 : 2;
const std::string num_bytes_str = std::string(1,num_bytes + 0x30);
bool in_extended = false;