yhirose 7 年之前
父節點
當前提交
d32eee7627
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      httplib.h

+ 3 - 2
httplib.h

@@ -923,10 +923,11 @@ inline std::string encode_url(const std::string& s)
         case ':':  result += "%3A"; break;
         case ';':  result += "%3B"; break;
         default:
-            if (s[i] < 0) {
+            auto c = static_cast<uint8_t>(s[i]);
+            if (c >= 0x80) {
                 result += '%';
                 char hex[4];
-                size_t len = snprintf(hex, sizeof(hex) - 1, "%02X", (unsigned char)s[i]);
+                size_t len = snprintf(hex, sizeof(hex) - 1, "%02X", c);
                 assert(len == 2);
                 result.append(hex, len);
             } else {