Support filenames with charset (thanks to John van der Kamp, Zarafa).

This commit is contained in:
Vincent Richard 2010-09-07 07:44:15 +00:00
parent c4d595624b
commit f1b5d7d7e2

View File

@ -25,6 +25,7 @@
#include "vmime/parserHelpers.hpp" #include "vmime/parserHelpers.hpp"
#include "vmime/text.hpp" #include "vmime/text.hpp"
#include "vmime/encoding.hpp"
namespace vmime namespace vmime
@ -322,7 +323,13 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
pos += name.length() + 1; pos += name.length() + 1;
} }
bool extended = false; // Check whether there is a recommended encoding for this charset.
// If so, the whole buffer will be encoded. Else, the number of
// 7-bit (ASCII) bytes in the input will be used to determine if
// we need to encode the whole buffer.
encoding recommendedEnc;
const bool alwaysEncode = m_value.getCharset().getRecommendedEncoding(recommendedEnc);
bool extended = alwaysEncode;
for (string::size_type i = 0 ; (i < value.length()) && (pos < maxLineLength - 4) ; ++i) for (string::size_type i = 0 ; (i < value.length()) && (pos < maxLineLength - 4) ; ++i)
{ {
@ -454,7 +461,8 @@ void parameter::generate(utility::outputStream& os, const string::size_type maxL
default: default:
encode = (!parserHelpers::isPrint(c) || encode = (!parserHelpers::isPrint(c) ||
!parserHelpers::isAscii(c)); !parserHelpers::isAscii(c) ||
alwaysEncode);
break; break;
} }