diff --git a/es-core/src/HttpReq.cpp b/es-core/src/HttpReq.cpp
index 5171da636..dfece200b 100644
--- a/es-core/src/HttpReq.cpp
+++ b/es-core/src/HttpReq.cpp
@@ -22,7 +22,7 @@ std::string HttpReq::urlEncode(const std::string &s)
         {
             escaped.append("%");
             char buf[3];
-            sprintf(buf, "%.2X", s[i]);
+            sprintf(buf, "%.2X", (unsigned char)s[i]);
             escaped.append(buf);
         }
     }