From 6bda214b0e5842a6f6814d4ae307b8bfefc5f292 Mon Sep 17 00:00:00 2001 From: Waldo Bastian Date: Sun, 4 Nov 2001 05:27:53 +0000 Subject: [PATCH] - /** Convert all non-ascii characters to question marks */ - static const QCString toUsAscii(const QString& _str); + /** Convert all non-ascii characters to question marks + * If ok is non-null, *ok will be set to true if all characters + * where ascii, *ok will be set to false otherwise */ + static const QCString toUsAscii(const QString& _str, bool *ok=0); svn path=/trunk/kdenetwork/kmail/; revision=120665 --- kmmsgbase.cpp | 12 +++++++++--- kmmsgbase.h | 6 ++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/kmmsgbase.cpp b/kmmsgbase.cpp index dbbce60e1..cc2b7666c 100644 --- a/kmmsgbase.cpp +++ b/kmmsgbase.cpp @@ -190,12 +190,18 @@ QTextCodec* KMMsgBase::codecForName(const QCString& _str) //----------------------------------------------------------------------------- -const QCString KMMsgBase::toUsAscii(const QString& _str) +const QCString KMMsgBase::toUsAscii(const QString& _str, bool *ok) { - QString result = _str; + bool all_ok =true; + QString result = _str; int len = result.length(); for (int i = 0; i < len; i++) - if (result.at(i).unicode() >= 128) result.at(i) = '?'; + if (result.at(i).unicode() >= 128) { + result.at(i) = '?'; + all_ok = false; + } + if (ok) + *ok = all_ok; return result.latin1(); } diff --git a/kmmsgbase.h b/kmmsgbase.h index 49f644862..c271f62e9 100644 --- a/kmmsgbase.h +++ b/kmmsgbase.h @@ -117,8 +117,10 @@ public: * This function is a bit more tolerant, than QTextCodec::codecForName */ static QTextCodec* codecForName(const QCString& _str); - /** Convert all non-ascii characters to question marks */ - static const QCString toUsAscii(const QString& _str); + /** Convert all non-ascii characters to question marks + * If ok is non-null, *ok will be set to true if all characters + * where ascii, *ok will be set to false otherwise */ + static const QCString toUsAscii(const QString& _str, bool *ok=0); /** Return a list of the supported encodings */ static QStringList supportedEncodings(bool usAscii);