kmail

stringutil.cpp
00001 /* Copyright 2009 Thomas McGuire <mcguire@kde.org>
00002 
00003    This program is free software; you can redistribute it and/or
00004    modify it under the terms of the GNU General Public License as
00005    published by the Free Software Foundation; either version 2 of
00006    the License or (at your option) version 3 or any later version
00007    accepted by the membership of KDE e.V. (or its successor approved
00008    by the membership of KDE e.V.), which shall act as a proxy
00009    defined in Section 14 of version 3 of the license.
00010 
00011    This program is distributed in the hope that it will be useful,
00012    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014    GNU General Public License for more details.
00015 
00016    You should have received a copy of the GNU General Public License
00017    along with this program.  If not, see <http://www.gnu.org/licenses/>.
00018 */
00019 #include "stringutil.h"
00020 #include "kmmsgbase.h"
00021 #include <kurl.h>
00022 
00023 namespace KMail
00024 {
00025 
00026 namespace StringUtil
00027 {
00028 #ifndef KMAIL_UNITTESTS
00029 TQString encodeMailtoUrl( const TQString& str )
00030 {
00031   TQString result;
00032   result = TQString::fromLatin1( KMMsgBase::encodeRFC2047String( str,
00033                                 "utf-8" ) );
00034   result = KURL::encode_string( result );
00035   return result;
00036 }
00037 
00038 TQString decodeMailtoUrl( const TQString& url )
00039 {
00040   TQString result;
00041   result = KURL::decode_string( url.latin1() );
00042   result = KMMsgBase::decodeRFC2047String( result.latin1() );
00043   return result;
00044 }
00045 #endif
00046 
00047 }
00048 
00049 }