7fcf24fa | 2019-06-13 02:26:25 | Michele Calgaro |
Extended kcharset API with new utility function. Signed-off-by: Michele Calgaro <michele.calgaro@...> |
||
M tdecore/kcharsets.cpp M tdecore/kcharsets.h |
||
tdecore/kcharsets.cppdiff --git a/tdecore/kcharsets.cpp b/tdecore/kcharsets.cpp index 23786c5..3483039 100644 --- a/tdecore/kcharsets.cpp +++ b/tdecore/kcharsets.cpp @@ -506,6 +506,17 @@ return name.left(right).stripWhiteSpace(); } +TQString KCharsets::descriptiveNameForEncoding( const TQString &encodingName ) +{ + for ( const LanguageForEncoding* pos = language_for_encoding; pos->index; ++pos ) { + if ( encodingName == TQString::fromLatin1( pos->index )) { + const TQString description = i18n( language_names[ pos->data ] ); + return i18n("Descriptive Encoding Name", "%1 ( %2 )"). arg ( description ). arg( encodingName ); + } + } + return TQString::null; +} + TQStringList KCharsets::descriptiveEncodingNames() { // As we are sorting, we can directly read the array language_for_encoding tdecore/kcharsets.hdiff --git a/tdecore/kcharsets.h b/tdecore/kcharsets.h index da96643..eeaf491 100644 --- a/tdecore/kcharsets.h +++ b/tdecore/kcharsets.h @@ -135,6 +135,13 @@ */ TQString encodingForName( const TQString &descriptiveName ); + /** + * Returns the descriptive encoding name for an encoding name. + * @param encodingName the name of the encoding + * @return the descriptive name for the encoding + */ + TQString descriptiveNameForEncoding( const TQString &encodingName ); + private: KCharsetsPrivate *d; }; |