diff options
Diffstat (limited to 'src/PercentEncodedCharacterDecoder.cpp')
-rw-r--r-- | src/PercentEncodedCharacterDecoder.cpp | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/PercentEncodedCharacterDecoder.cpp b/src/PercentEncodedCharacterDecoder.cpp index d3bc0d9..890d392 100644 --- a/src/PercentEncodedCharacterDecoder.cpp +++ b/src/PercentEncodedCharacterDecoder.cpp @@ -10,6 +10,21 @@ #include "IsCharacterInSet.hpp" #include "PercentEncodedCharacterDecoder.hpp" +namespace { + + /** + * This is the character set containing just numbers. + */ + const Uri::CharacterSet DIGIT('0', '9'); + + /** + * This is the character set containing just the upper-case + * letters 'A' through 'F', used in upper-case hexadecimal. + */ + const Uri::CharacterSet HEX('A', 'F'); + +} + namespace Uri { struct PercentEncodedCharacterDecoder::Impl { @@ -41,9 +56,9 @@ namespace Uri { case 0: { // % ... impl_->decoderState = 1; impl_->decodedCharacter <<= 4; - if (IsCharacterInSet(c, {'0','9'})) { + if (IsCharacterInSet(c, DIGIT)) { impl_->decodedCharacter += (int)(c - '0'); - } else if (IsCharacterInSet(c, {'A','F'})) { + } else if (IsCharacterInSet(c, HEX)) { impl_->decodedCharacter += (int)(c - 'A') + 10; } else { return false; @@ -53,9 +68,9 @@ namespace Uri { case 1: { // %[0-9A-F] ... impl_->decoderState = 2; impl_->decodedCharacter <<= 4; - if (IsCharacterInSet(c, {'0','9'})) { + if (IsCharacterInSet(c, DIGIT)) { impl_->decodedCharacter += (int)(c - '0'); - } else if (IsCharacterInSet(c, {'A','F'})) { + } else if (IsCharacterInSet(c, HEX)) { impl_->decodedCharacter += (int)(c - 'A') + 10; } else { return false; |