diff options
author | Vincent Richard <[email protected]> | 2010-02-01 13:06:06 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2010-02-01 13:06:06 +0000 |
commit | 625fd5f1568be00da72c0a8b60ef1aabac485e1c (patch) | |
tree | ab5756ccc87e244bf348ad8651f0feb73747ffe2 | |
parent | Fixed bug #2933667: CRLF filter broken. (diff) | |
download | vmime-625fd5f1568be00da72c0a8b60ef1aabac485e1c.tar.gz vmime-625fd5f1568be00da72c0a8b60ef1aabac485e1c.zip |
Fixed bug #2927077: account for multi-byte charsets in invalid sequence output.
-rw-r--r-- | src/charsetConverter.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/charsetConverter.cpp b/src/charsetConverter.cpp index ec74ae52..798adf07 100644 --- a/src/charsetConverter.cpp +++ b/src/charsetConverter.cpp @@ -121,7 +121,18 @@ void charsetConverter::convert(utility::inputStream& in, utility::outputStream& // Output a special character to indicate we don't known how to // convert the sequence at this position - out.write("?", 1); + const char* invalidCharIn = "?"; + size_t invalidCharInLen = 1; + + char invalidCharOutBuffer[16]; + char* invalidCharOutPtr = invalidCharOutBuffer; + size_t invalidCharOutLen = 16; + + if (iconv(cd, ICONV_HACK(&invalidCharIn), &invalidCharInLen, + &invalidCharOutPtr, &invalidCharOutLen) != static_cast <size_t>(-1)) + { + out.write(invalidCharOutBuffer, 16 - invalidCharOutLen); + } // Skip a byte and leave unconverted bytes in the input buffer std::copy(const_cast <char*>(inPtr + 1), inBuffer + sizeof(inBuffer), inBuffer); |