URLエンコードを日本語対応

This commit is contained in:
keita
2021-02-17 14:02:06 +09:00
parent e87f59bd94
commit 8c5ec96695
+2 -1
View File
@@ -1,5 +1,6 @@
#include "cocoatweet/util/util.h" #include "cocoatweet/util/util.h"
#include <cctype> #include <cctype>
#include <iomanip>
namespace CocoaTweet::Util { namespace CocoaTweet::Util {
std::string urlEncode(const std::string& _str) { std::string urlEncode(const std::string& _str) {
@@ -10,7 +11,7 @@ std::string urlEncode(const std::string& _str) {
(c == '.' || (c == '_') || (c == '-' || (c == '~')))) { (c == '.' || (c == '_') || (c == '-' || (c == '~')))) {
out << c; out << c;
} else { } else {
out << '%' << std::hex << std::uppercase << static_cast<int>(c); out << '%' << std::setw(2) << std::setfill('0') << std::hex << std::uppercase << (0xFF & static_cast<int>(c));
} }
} }