diff --git a/src/Desc.cc b/src/Desc.cc index 2faaf48587..3db2820bb6 100644 --- a/src/Desc.cc +++ b/src/Desc.cc @@ -261,7 +261,7 @@ size_t check_utf8 (const char* bytes, size_t n, size_t i) { // Check if this is infact a multibyte UTF-8 sequence, // which requires a 1 to be the first bit of the first byte - if (!(bytes[i] >> 7 & 1)) + if (!(bytes[i] >> 7 & 1)) return 0; // Checks two to four bytes from starting position i @@ -291,7 +291,12 @@ pair ODesc::FirstEscapeLoc(const char* bytes, size_t n) if (bytes[i] == '\\' ) return escape_pos(bytes + i, 1); - else if (!isprint(bytes[i])) + size_t len = StartsWithEscapeSequence(bytes + i, bytes + n); + + if ( len ) + return escape_pos(bytes + i, len); + + if (!isprint(bytes[i])) { if (utf8) { @@ -305,10 +310,6 @@ pair ODesc::FirstEscapeLoc(const char* bytes, size_t n) return escape_pos(bytes + i, 1); } - size_t len = StartsWithEscapeSequence(bytes + i, bytes + n); - - if ( len ) - return escape_pos(bytes + i, len); } return escape_pos(0, 0);