diff --git a/winixd/core/misc.h b/winixd/core/misc.h index d0f7246..ad70e8f 100644 --- a/winixd/core/misc.h +++ b/winixd/core/misc.h @@ -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 +void q_encode( + const pt::TextStreamBase & in, + pt::TextStreamBase & 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::const_iterator i = in.begin(); + + for( ; i != in.end() ; ++i) + QEncodeAddChar(*i, out); + + out << "?="; +} + } // namespace Winix