diff options
author | Vincent Richard <[email protected]> | 2013-02-24 15:28:13 +0000 |
---|---|---|
committer | Vincent Richard <[email protected]> | 2013-02-24 15:28:13 +0000 |
commit | 0c5d4a10e6f616f5a63787b8fbda86ec9fc487a9 (patch) | |
tree | c04b535bffeeba3e95adae01b961740bdc3a938e /src/utility/stringUtils.cpp | |
parent | Fixed filename case. (diff) | |
download | vmime-0c5d4a10e6f616f5a63787b8fbda86ec9fc487a9.tar.gz vmime-0c5d4a10e6f616f5a63787b8fbda86ec9fc487a9.zip |
Message generation/parsing context. Charset conversion options. Preliminary implementation of RFC-6532.
Diffstat (limited to 'src/utility/stringUtils.cpp')
-rw-r--r-- | src/utility/stringUtils.cpp | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/utility/stringUtils.cpp b/src/utility/stringUtils.cpp index ad498342..8e5f7205 100644 --- a/src/utility/stringUtils.cpp +++ b/src/utility/stringUtils.cpp @@ -151,6 +151,12 @@ string::size_type stringUtils::countASCIIchars } +bool stringUtils::is7bit(const string& str) +{ + return countASCIIchars(str.begin(), str.end()) == str.length(); +} + + string::size_type stringUtils::findFirstNonASCIIchar (const string::const_iterator begin, const string::const_iterator end) { @@ -205,5 +211,32 @@ const string stringUtils::unquote(const string& str) } +bool stringUtils::needQuoting(const string& str, const string& specialChars) +{ + return str.find_first_of(specialChars.c_str()) != string::npos; +} + + +string stringUtils::quote + (const string& str, const string& escapeSpecialChars, const string& escapeChar) +{ + std::ostringstream oss; + string::size_type lastPos = 0, pos = 0; + + while ((pos = str.find_first_of(escapeSpecialChars, lastPos)) != string::npos) + { + oss << str.substr(lastPos, pos - lastPos) + << escapeChar + << str[pos]; + + lastPos = pos + 1; + } + + oss << str.substr(lastPos); + + return oss.str(); +} + + } // utility } // vmime |