37 size_t length_of_string = s.length();
38 if (!length_of_string)
return std::string(
"");
40 size_t in_len = length_of_string;
49 size_t approx_length_of_decoded_string = length_of_string / 4 * 3;
51 ret.reserve(approx_length_of_decoded_string);
53 while (pos < in_len) {
55 unsigned int pos_of_char_1 = pos_of_char(s[pos+1] );
57 ret.push_back(
static_cast<std::string::value_type
>( ( (pos_of_char(s[pos+0]) ) << 2 ) + ( (pos_of_char_1 & 0x30 ) >> 4)));
59 if (s[pos+2] !=
'=' && s[pos+2] !=
'.') {
61 unsigned int pos_of_char_2 = pos_of_char(s[pos+2] );
62 ret.push_back(
static_cast<std::string::value_type
>( (( pos_of_char_1 & 0x0f) << 4) + (( pos_of_char_2 & 0x3c) >> 2)));
64 if (s[pos+3] !=
'=' && s[pos+3] !=
'.') {
65 ret.push_back(
static_cast<std::string::value_type
>( ( (pos_of_char_2 & 0x03 ) << 6 ) + pos_of_char(s[pos+3]) ));