diff --git a/src/string_util.cpp b/src/string_util.cpp index 9286ed4..6e847e6 100644 --- a/src/string_util.cpp +++ b/src/string_util.cpp @@ -163,7 +163,7 @@ std::string urlEncode(const std::string &s) result += c; }else{ result += "%"; - result += s3fs_hex(&c, 1); + result += s3fs_hex(&c, 1, false); } } return result; @@ -193,7 +193,7 @@ std::string urlEncode2(const std::string &s) result += c; }else{ result += "%"; - result += s3fs_hex(&c, 1); + result += s3fs_hex(&c, 1, false); } } return result; @@ -373,9 +373,12 @@ bool convert_unixtime_from_option_arg(const char* argv, time_t& unixtime) return true; } -std::string s3fs_hex(const unsigned char* input, size_t length) +std::string s3fs_hex(const unsigned char* input, size_t length, bool lower) { - static const char hexAlphabet[] = "0123456789abcdef"; + static const char hexLower[] = "0123456789abcdef"; + static const char hexUpper[] = "0123456789ABCDEF"; + + const char* hexAlphabet = (lower ? hexLower : hexUpper); std::string hex; for(size_t pos = 0; pos < length; ++pos){ hex += hexAlphabet[input[pos] / 16]; diff --git a/src/string_util.h b/src/string_util.h index d5de722..427e8f7 100644 --- a/src/string_util.h +++ b/src/string_util.h @@ -92,7 +92,7 @@ bool get_keyword_value(std::string& target, const char* keyword, std::string& va // // For binary string // -std::string s3fs_hex(const unsigned char* input, size_t length); +std::string s3fs_hex(const unsigned char* input, size_t length, bool lower = true); char* s3fs_base64(const unsigned char* input, size_t length); unsigned char* s3fs_decode64(const char* input, size_t* plength);