summaryrefslogtreecommitdiff
path: root/cpp/src/IceUtil/StringUtil.cpp
diff options
context:
space:
mode:
authorMatthew Newhook <matthew@zeroc.com>2005-12-16 17:16:05 +0000
committerMatthew Newhook <matthew@zeroc.com>2005-12-16 17:16:05 +0000
commit20de27fa7ed8ba789c0859b8e858610419fcb2c6 (patch)
tree2ab9a32b38b2c95231d509d57302f544639c5b9d /cpp/src/IceUtil/StringUtil.cpp
parentadded file. (diff)
downloadice-20de27fa7ed8ba789c0859b8e858610419fcb2c6.tar.bz2
ice-20de27fa7ed8ba789c0859b8e858610419fcb2c6.tar.xz
ice-20de27fa7ed8ba789c0859b8e858610419fcb2c6.zip
http://bugzilla.zeroc.com/bugzilla/show_bug.cgi?id=679
Diffstat (limited to 'cpp/src/IceUtil/StringUtil.cpp')
-rw-r--r--cpp/src/IceUtil/StringUtil.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/cpp/src/IceUtil/StringUtil.cpp b/cpp/src/IceUtil/StringUtil.cpp
index 89c4013f2c3..954394fcc25 100644
--- a/cpp/src/IceUtil/StringUtil.cpp
+++ b/cpp/src/IceUtil/StringUtil.cpp
@@ -76,10 +76,14 @@ escapeChar(string::value_type b, string& s, const string& special)
}
default:
{
- if(static_cast<signed char>(b) <= 31 || b == 127)
+ //
+ // Octal encode anything that is outside 32 to 126.
+ //
+ unsigned char i = static_cast<unsigned char>(b);
+ if(i < 32 || i > 126)
{
s.push_back('\\');
- string octal = toOctalString(b);
+ string octal = toOctalString(i);
//
// Add leading zeroes so that we avoid problems during
@@ -208,14 +212,15 @@ IceUtil::unescapeString(const string& s, string::size_type start, string::size_t
}
default:
{
- if(static_cast<signed char>(ch) <= 31 || ch == 127)
- {
- return false; // Malformed encoding.
- }
- else
- {
- result.push_back(ch);
- }
+ unsigned char i = static_cast<unsigned char>(ch);
+ if(i < 32 || i > 126)
+ {
+ return false; // Malformed encoding.
+ }
+ else
+ {
+ result.push_back(ch);
+ }
}
}
}