Imbue classic 'C' locale for the output of message parts and protocol commands.
This commit is contained in:
parent
c2ec474b03
commit
f99fc84915
@ -2,6 +2,11 @@
|
||||
VERSION 0.8.1cvs
|
||||
================
|
||||
|
||||
2006-11-08 Vincent Richard <vincent@vincent-richard.net>
|
||||
|
||||
* Imbue classic "C" locale for the output of message parts and
|
||||
protocol commands (thanks to Mörtsell Anders).
|
||||
|
||||
2006-10-11 Vincent Richard <vincent@vincent-richard.net>
|
||||
|
||||
* Renamed 'vmime::platformDependant' to 'vmime::platform'. The old
|
||||
|
@ -600,6 +600,8 @@ void datetime::generate(utility::outputStream& os, const string::size_type /* ma
|
||||
const int zm = z % 60;
|
||||
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale::classic());
|
||||
|
||||
oss << dayNames[getWeekDay()] << ", "
|
||||
<< m_day << " " << monthNames[m_month - 1] << " " << m_year
|
||||
<< " " << std::setfill('0') << std::setw(2) << m_hour << ":"
|
||||
|
@ -210,6 +210,7 @@ messageId& messageId::operator=(const string& id)
|
||||
messageId messageId::generateId()
|
||||
{
|
||||
std::ostringstream left;
|
||||
left.imbue(std::locale::classic());
|
||||
|
||||
left << "vmime";
|
||||
left << '.';
|
||||
|
@ -821,6 +821,8 @@ void IMAPFolder::deleteMessage(const int num)
|
||||
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "STORE " << num << " +FLAGS.SILENT (\\Deleted)";
|
||||
|
||||
// Send the request
|
||||
@ -875,6 +877,8 @@ void IMAPFolder::deleteMessages(const int from, const int to)
|
||||
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "STORE " << from << ":";
|
||||
|
||||
if (to == -1) command << m_messageCount;
|
||||
@ -948,6 +952,8 @@ void IMAPFolder::deleteMessages(const std::vector <int>& nums)
|
||||
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "STORE ";
|
||||
command << IMAPUtils::listToSet(list, m_messageCount, true);
|
||||
command << " +FLAGS.SILENT (\\Deleted)";
|
||||
@ -1000,6 +1006,7 @@ void IMAPFolder::setMessageFlags(const int from, const int to, const int flags,
|
||||
throw exceptions::illegal_state("Folder is read-only");
|
||||
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale::classic());
|
||||
|
||||
if (to == -1)
|
||||
oss << from << ":*";
|
||||
@ -1159,6 +1166,8 @@ void IMAPFolder::setMessageFlags(const string& set, const int flags, const int m
|
||||
{
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "STORE " << set;
|
||||
|
||||
switch (mode)
|
||||
@ -1220,6 +1229,8 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int
|
||||
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "APPEND " << IMAPUtils::quoteString(IMAPUtils::pathToString
|
||||
(m_connection->hierarchySeparator(), getFullPath())) << ' ';
|
||||
|
||||
@ -1433,6 +1444,8 @@ void IMAPFolder::rename(const folder::path& newPath)
|
||||
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "RENAME ";
|
||||
command << IMAPUtils::quoteString(IMAPUtils::pathToString
|
||||
(m_connection->hierarchySeparator(), getFullPath())) << " ";
|
||||
@ -1506,6 +1519,8 @@ void IMAPFolder::copyMessage(const folder::path& dest, const int num)
|
||||
|
||||
// Construct set
|
||||
std::ostringstream set;
|
||||
set.imbue(std::locale::classic());
|
||||
|
||||
set << num;
|
||||
|
||||
// Delegate message copy
|
||||
@ -1544,6 +1559,7 @@ void IMAPFolder::copyMessages(const folder::path& dest, const int from, const in
|
||||
|
||||
// Construct set
|
||||
std::ostringstream set;
|
||||
set.imbue(std::locale::classic());
|
||||
|
||||
if (to == -1)
|
||||
set << from << ":*";
|
||||
@ -1614,6 +1630,8 @@ void IMAPFolder::copyMessages(const string& set, const folder::path& dest)
|
||||
{
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "COPY " << set << " ";
|
||||
command << IMAPUtils::quoteString(IMAPUtils::pathToString
|
||||
(m_connection->hierarchySeparator(), dest));
|
||||
@ -1642,6 +1660,8 @@ void IMAPFolder::status(int& count, int& unseen)
|
||||
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "STATUS ";
|
||||
command << IMAPUtils::quoteString(IMAPUtils::pathToString
|
||||
(m_connection->hierarchySeparator(), getFullPath()));
|
||||
|
@ -409,6 +409,7 @@ void IMAPMessage::extract(ref <const part> p, utility::outputStream& os,
|
||||
|
||||
// Construct section identifier
|
||||
std::ostringstream section;
|
||||
section.imbue(std::locale::classic());
|
||||
|
||||
if (p != NULL)
|
||||
{
|
||||
@ -435,6 +436,7 @@ void IMAPMessage::extract(ref <const part> p, utility::outputStream& os,
|
||||
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "FETCH " << m_num << " BODY";
|
||||
if (peek) command << ".PEEK";
|
||||
@ -545,6 +547,8 @@ void IMAPMessage::processFetchResponse
|
||||
case IMAPParser::msg_att_item::UID:
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale::classic());
|
||||
|
||||
oss << folder->m_uidValidity << ":" << (*it)->unique_id()->value();
|
||||
|
||||
m_uid = oss.str();
|
||||
@ -685,6 +689,8 @@ void IMAPMessage::setFlags(const int flags, const int mode)
|
||||
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "STORE " << m_num;
|
||||
|
||||
switch (mode)
|
||||
|
@ -390,6 +390,8 @@ const string IMAPUtils::messageFlagList(const int flags)
|
||||
if (!flagList.empty())
|
||||
{
|
||||
std::ostringstream res;
|
||||
res.imbue(std::locale::classic());
|
||||
|
||||
res << "(";
|
||||
|
||||
if (flagList.size() >= 2)
|
||||
@ -426,6 +428,8 @@ const string IMAPUtils::listToSet(const std::vector <int>& list, const int max,
|
||||
|
||||
// Build the set
|
||||
std::ostringstream res;
|
||||
res.imbue(std::locale::classic());
|
||||
|
||||
int previous = -1, setBegin = -1;
|
||||
|
||||
for (std::vector <int>::const_iterator it = theList.begin() ;
|
||||
@ -483,6 +487,7 @@ const string IMAPUtils::listToSet(const std::vector <int>& list, const int max,
|
||||
const string IMAPUtils::dateTime(const vmime::datetime& date)
|
||||
{
|
||||
std::ostringstream res;
|
||||
res.imbue(std::locale::classic());
|
||||
|
||||
// date_time ::= <"> date_day_fixed "-" date_month "-" date_year
|
||||
// SPACE time SPACE zone <">
|
||||
@ -608,6 +613,8 @@ const string IMAPUtils::buildFetchRequest(const std::vector <int>& list, const i
|
||||
|
||||
// Build the request text
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "FETCH " << listToSet(list, -1, false) << " (";
|
||||
|
||||
for (std::vector <string>::const_iterator it = items.begin() ;
|
||||
|
@ -203,6 +203,7 @@ const utility::file::path::component maildirUtils::buildFilename
|
||||
const utility::file::path::component maildirUtils::generateId()
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale::classic());
|
||||
|
||||
oss << utility::random::getTime();
|
||||
oss << ".";
|
||||
|
@ -443,6 +443,8 @@ void POP3Folder::fetchMessage(ref <message> msg, const int options)
|
||||
{
|
||||
// Send the "LIST" command
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "LIST " << msg->getNumber();
|
||||
|
||||
store->sendRequest(command.str());
|
||||
@ -479,6 +481,8 @@ void POP3Folder::fetchMessage(ref <message> msg, const int options)
|
||||
{
|
||||
// Send the "UIDL" command
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "UIDL " << msg->getNumber();
|
||||
|
||||
store->sendRequest(command.str());
|
||||
@ -566,6 +570,8 @@ void POP3Folder::deleteMessage(const int num)
|
||||
throw exceptions::illegal_state("Folder not open");
|
||||
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "DELE " << num;
|
||||
|
||||
store->sendRequest(command.str());
|
||||
@ -615,6 +621,8 @@ void POP3Folder::deleteMessages(const int from, const int to)
|
||||
for (int i = from ; i <= to2 ; ++i)
|
||||
{
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "DELE " << i;
|
||||
|
||||
store->sendRequest(command.str());
|
||||
@ -666,6 +674,8 @@ void POP3Folder::deleteMessages(const std::vector <int>& nums)
|
||||
it = nums.begin() ; it != nums.end() ; ++it)
|
||||
{
|
||||
std::ostringstream command;
|
||||
command.imbue(std::locale::classic());
|
||||
|
||||
command << "DELE " << (*it);
|
||||
|
||||
store->sendRequest(command.str());
|
||||
|
@ -125,7 +125,9 @@ void parameter::parse(const std::vector <valueChunk>& chunks)
|
||||
bool foundCharsetChunk = false;
|
||||
|
||||
charset ch(charsets::US_ASCII);
|
||||
|
||||
std::ostringstream value;
|
||||
value.imbue(std::locale::classic());
|
||||
|
||||
for (std::vector <valueChunk>::size_type i = 0 ; i < chunks.size() ; ++i)
|
||||
{
|
||||
|
@ -376,6 +376,8 @@ void posixChildProcess::waitForFinish()
|
||||
else
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale::classic());
|
||||
|
||||
oss << "Process exited with status " << WEXITSTATUS(wstat);
|
||||
|
||||
throw exceptions::system_error(oss.str());
|
||||
|
@ -78,6 +78,8 @@ void posixSocket::connect(const vmime::string& address, const vmime::port_t port
|
||||
hints.ai_socktype = SOCK_STREAM;
|
||||
|
||||
std::ostringstream portStr;
|
||||
portStr.imbue(std::locale::classic());
|
||||
|
||||
portStr << port;
|
||||
|
||||
struct ::addrinfo* res0;
|
||||
|
@ -39,6 +39,7 @@ const string messageDigest::getHexDigest() const
|
||||
static const unsigned char hex[] = "0123456789abcdef";
|
||||
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale::classic());
|
||||
|
||||
for (int i = 0 ; i < len ; ++i)
|
||||
{
|
||||
|
@ -33,10 +33,13 @@ const bool stringUtils::isStringEqualNoCase
|
||||
if (s1.length() < n)
|
||||
return (false);
|
||||
|
||||
const std::ctype <unsigned char>& fac =
|
||||
std::use_facet <std::ctype <unsigned char> >(std::locale::classic());
|
||||
|
||||
bool equal = true;
|
||||
|
||||
for (string::size_type i = 0 ; equal && i < n ; ++i)
|
||||
equal = (std::tolower(s1[i], std::locale()) == s2[i]);
|
||||
equal = (fac.tolower(static_cast <unsigned char>(s1[i])) == s2[i]);
|
||||
|
||||
return (equal);
|
||||
}
|
||||
@ -47,11 +50,14 @@ const bool stringUtils::isStringEqualNoCase(const string& s1, const string& s2)
|
||||
if (s1.length() != s2.length())
|
||||
return (false);
|
||||
|
||||
const std::ctype <unsigned char>& fac =
|
||||
std::use_facet <std::ctype <unsigned char> >(std::locale::classic());
|
||||
|
||||
bool equal = true;
|
||||
const string::const_iterator end = s1.end();
|
||||
|
||||
for (string::const_iterator i = s1.begin(), j = s2.begin(); i != end ; ++i, ++j)
|
||||
equal = (std::tolower(*i, std::locale()) == std::tolower(*j, std::locale()));
|
||||
equal = (fac.tolower(static_cast <unsigned char>(*i)) == fac.tolower(static_cast <unsigned char>(*j)));
|
||||
|
||||
return (equal);
|
||||
}
|
||||
@ -64,12 +70,15 @@ const bool stringUtils::isStringEqualNoCase
|
||||
if (static_cast <string::size_type>(end - begin) < n)
|
||||
return (false);
|
||||
|
||||
const std::ctype <unsigned char>& fac =
|
||||
std::use_facet <std::ctype <unsigned char> >(std::locale::classic());
|
||||
|
||||
bool equal = true;
|
||||
char* c = const_cast<char*>(s);
|
||||
string::size_type r = n;
|
||||
|
||||
for (string::const_iterator i = begin ; equal && r && *c ; ++i, ++c, --r)
|
||||
equal = (std::tolower(*i, std::locale()) == *c);
|
||||
equal = (fac.tolower(static_cast <unsigned char>(*i)) == static_cast <unsigned char>(*c));
|
||||
|
||||
return (r == 0 && equal);
|
||||
}
|
||||
@ -77,11 +86,14 @@ const bool stringUtils::isStringEqualNoCase
|
||||
|
||||
const string stringUtils::toLower(const string& str)
|
||||
{
|
||||
const std::ctype <unsigned char>& fac =
|
||||
std::use_facet <std::ctype <unsigned char> >(std::locale::classic());
|
||||
|
||||
string out;
|
||||
out.resize(str.size());
|
||||
|
||||
for (string::size_type i = 0, len = str.length() ; i < len ; ++i)
|
||||
out[i] = std::tolower(str[i], std::locale());
|
||||
out[i] = fac.tolower(static_cast <unsigned char>(str[i]));
|
||||
|
||||
return out;
|
||||
}
|
||||
@ -89,11 +101,14 @@ const string stringUtils::toLower(const string& str)
|
||||
|
||||
const string stringUtils::toUpper(const string& str)
|
||||
{
|
||||
const std::ctype <unsigned char>& fac =
|
||||
std::use_facet <std::ctype <unsigned char> >(std::locale::classic());
|
||||
|
||||
string out;
|
||||
out.resize(str.size());
|
||||
|
||||
for (string::size_type i = 0, len = str.length() ; i < len ; ++i)
|
||||
out[i] = std::toupper(str[i], std::locale());
|
||||
out[i] = fac.toupper(static_cast <unsigned char>(str[i]));
|
||||
|
||||
return out;
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ url::operator string() const
|
||||
const string url::build() const
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale::classic());
|
||||
|
||||
oss << m_protocol << "://";
|
||||
|
||||
|
@ -164,6 +164,8 @@ template <typename T>
|
||||
outputStream& operator<<(outputStream& os, const T& t)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale::classic()); // no formatting
|
||||
|
||||
oss << t;
|
||||
|
||||
os << oss.str();
|
||||
|
@ -113,6 +113,8 @@ public:
|
||||
static const string toString(const TYPE& value)
|
||||
{
|
||||
std::ostringstream oss;
|
||||
oss.imbue(std::locale::classic());
|
||||
|
||||
oss << value;
|
||||
|
||||
return (oss.str());
|
||||
@ -130,6 +132,8 @@ public:
|
||||
TYPE ret;
|
||||
|
||||
std::istringstream iss(value);
|
||||
iss.imbue(std::locale::classic());
|
||||
|
||||
iss >> ret;
|
||||
|
||||
return (ret);
|
||||
|
Loading…
Reference in New Issue
Block a user