MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / uri_decode

Method uri_decode

core/string/ustring.cpp:4668–4691  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4666}
4667
4668String String::uri_decode() const {
4669 CharString src = utf8();
4670 CharString res;
4671 for (int i = 0; i < src.length(); ++i) {
4672 if (src[i] == '%' && i + 2 < src.length()) {
4673 char ord1 = src[i + 1];
4674 if (is_digit(ord1) || is_ascii_upper_case(ord1)) {
4675 char ord2 = src[i + 2];
4676 if (is_digit(ord2) || is_ascii_upper_case(ord2)) {
4677 char bytes[3] = { (char)ord1, (char)ord2, 0 };
4678 res += (char)strtol(bytes, nullptr, 16);
4679 i += 2;
4680 }
4681 } else {
4682 res += src[i];
4683 }
4684 } else if (src[i] == '+') {
4685 res += ' ';
4686 } else {
4687 res += src[i];
4688 }
4689 }
4690 return String::utf8(res);
4691}
4692
4693String String::uri_file_decode() const {
4694 CharString src = utf8();

Callers 2

update_treeMethod · 0.80
test_string.hFile · 0.80

Calls 3

is_digitFunction · 0.85
is_ascii_upper_caseFunction · 0.85
lengthMethod · 0.45

Tested by 1

update_treeMethod · 0.64