add a q_encode(...) method to misc

This commit is contained in:
Tomasz Sowa 2024-04-28 16:14:57 +02:00
parent 140b4495df
commit 1c850b12ec
Signed by: tomasz.sowa
GPG Key ID: 662CC1438638588B
1 changed files with 21 additions and 1 deletions

View File

@ -5,7 +5,7 @@
*/
/*
* Copyright (c) 2008-2023, Tomasz Sowa
* Copyright (c) 2008-2024, Tomasz Sowa
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -1074,6 +1074,26 @@ void prepare_cookie_string(
bool secure = false);
template<typename char_type, size_t stack_size, size_t heap_block_size>
void q_encode(
const pt::TextStreamBase<char_type, stack_size, heap_block_size> & in,
pt::TextStreamBase<char_type, stack_size, heap_block_size> & out,
bool clear = true)
{
if( clear )
out.clear();
out << "=?UTF-8?Q?";
// do not use QEncode(in.c_str()) as 'in' can have a null-terminating byte
typename pt::TextStreamBase<char_type, stack_size, heap_block_size>::const_iterator i = in.begin();
for( ; i != in.end() ; ++i)
QEncodeAddChar(*i, out);
out << "?=";
}
} // namespace Winix