<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <title>KCharsets</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <link rel="stylesheet" type="text/css" href="../common/doxygen.css" /> <link rel="stylesheet" media="screen" type="text/css" title="KDE Colors" href="../common/kde.css" /> </head> <body> <div id="container"> <div id="header"> <div id="header_top"> <div> <div> <img alt ="" src="../common/top-kde.jpg"/> KDE 4.4 PyKDE API Reference </div> </div> </div> <div id="header_bottom"> <div id="location"> <ul> <li>KDE's Python API</li> </ul> </div> <div id="menu"> <ul> <li><a href="../modules.html">Overview</a></li> <li><a href="http://techbase.kde.org/Development/Languages/Python">PyKDE Home</a></li> <li><a href="http://kde.org/family/">Sitemap</a></li> <li><a href="http://kde.org/contact/">Contact Us</a></li> </ul> </div> </div> </div> <div id="body_wrapper"> <div id="body"> <div id="right"> <div class="content"> <div id="main"> <div class="clearer"> </div> <h1>KCharsets Class Reference</h1> <code>from PyKDE4.kdecore import *</code> <p> <h2>Detailed Description</h2> <p>Charset font and encoder/decoder handling. </p> <p> This is needed, because Qt's encoding name matching in QTextCodec.codecForName matches only closely-related encoded names but not alternate names, e.g. found in the reality of the Internet. </p> <table border="0" cellpadding="0" cellspacing="0"><tr><td colspan="2"><br><h2>Methods</h2></td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#KCharsets">__init__</a> (self)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"> </td><td class="memItemRight" valign="bottom"><a class="el" href="#KCharsets">__init__</a> (self, <a href="../kdecore/KCharsets.html">KCharsets</a> other)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstringlist.html">QStringList</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#availableEncodingNames">availableEncodingNames</a> (self)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtextcodec.html">QTextCodec</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#codecForName">codecForName</a> (self, <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> name)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtextcodec.html">QTextCodec</a>, bool ok </td><td class="memItemRight" valign="bottom"><a class="el" href="#codecForName">codecForName2</a> (self, <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> n)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#descriptionForEncoding">descriptionForEncoding</a> (self, <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> encoding)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstringlist.html">QStringList</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#descriptiveEncodingNames">descriptiveEncodingNames</a> (self)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#encodingForName">encodingForName</a> (self, <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> descriptiveName)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top">[<a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstringlist.html">QStringList</a>] </td><td class="memItemRight" valign="bottom"><a class="el" href="#encodingsByScript">encodingsByScript</a> (self)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qchar.html">QChar</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#fromEntity">fromEntity</a> (self, <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> str)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qchar.html">QChar</a>, int len </td><td class="memItemRight" valign="bottom"><a class="el" href="#fromEntity">fromEntity2</a> (self, <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> str)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#languageForEncoding">languageForEncoding</a> (self, <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> encoding)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#resolveEntities">resolveEntities</a> (self, <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> text)</td></tr> <tr><td class="memItemLeft" nowrap align="right" valign="top"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td><td class="memItemRight" valign="bottom"><a class="el" href="#toEntity">toEntity</a> (self, <a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qchar.html">QChar</a> ch)</td></tr> </table> <hr><h2>Method Documentation</h2><a class="anchor" name="KCharsets"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">__init__</td> <td>(</td> <td class="paramtype"> </td> <td class="paramname"><em>self</em> )</td> <td width="100%"> </td> </tr> </table> </div> <div class="memdoc"><p>Protected constructor. If you need the kcharsets object, use KGlobal.charsets() instead. </p></div></div><a class="anchor" name="KCharsets"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">__init__</td> <td>(</td> <td class="paramtype"> <em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="../kdecore/KCharsets.html">KCharsets</a> </td> <td class="paramname"><em>other</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"></div></div><a class="anchor" name="availableEncodingNames"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstringlist.html">QStringList</a> availableEncodingNames</td> <td>(</td> <td class="paramtype"> </td> <td class="paramname"><em>self</em> )</td> <td width="100%"> </td> </tr> </table> </div> <div class="memdoc"><p>Lists all available encodings as names. <dl class="return" compact><dt><b>Returns:</b></dt><dd> the list of all encodings </dd></dl> </p></div></div><a class="anchor" name="codecForName"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtextcodec.html">QTextCodec</a> codecForName</td> <td>(</td> <td class="paramtype"> <em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td> <td class="paramname"><em>name</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Tries to find a QTextCodec to convert the given encoding from and to Unicode. </p> <p> If no codec could be found, the ISO 8859-1 codec will be returned an and <b>ok</b> will be set to false. </p> <p> </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>n</em> </td><td> the name of the codec <tr><td></td><td valign="top"><em>ok</em> </td><td> true if a matching codec has been found, false if not </td></tr> </table></dl> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> the QTextCodec. If the desired codec could not be found, it returns a default (ISO 8859-1) codec </dd></dl> </p></div></div><a class="anchor" name="codecForName"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtextcodec.html">QTextCodec</a>, bool ok codecForName2</td> <td>(</td> <td class="paramtype"> <em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td> <td class="paramname"><em>n</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Tries to find a QTextCodec to convert the given encoding from and to Unicode. </p> <p> If no codec could be found, the ISO 8859-1 codec will be returned an and <b>ok</b> will be set to false. </p> <p> </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>n</em> </td><td> the name of the codec <tr><td></td><td valign="top"><em>ok</em> </td><td> true if a matching codec has been found, false if not </td></tr> </table></dl> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> the QTextCodec. If the desired codec could not be found, it returns a default (ISO 8859-1) codec </dd></dl> </p></div></div><a class="anchor" name="descriptionForEncoding"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> descriptionForEncoding</td> <td>(</td> <td class="paramtype"> <em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td> <td class="paramname"><em>encoding</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Returns a long description for an encoding name. </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>encoding</em> </td><td> the encoding for the language </td></tr> </table></dl> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> the long description for the encoding </dd></dl> </p></div></div><a class="anchor" name="descriptiveEncodingNames"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstringlist.html">QStringList</a> descriptiveEncodingNames</td> <td>(</td> <td class="paramtype"> </td> <td class="paramname"><em>self</em> )</td> <td width="100%"> </td> </tr> </table> </div> <div class="memdoc"><p>Lists the available encoding names together with a more descriptive language. <dl class="return" compact><dt><b>Returns:</b></dt><dd> the list of descriptive encoding names </dd></dl> </p></div></div><a class="anchor" name="encodingForName"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> encodingForName</td> <td>(</td> <td class="paramtype"> <em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td> <td class="paramname"><em>descriptiveName</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Returns the encoding for a string obtained with descriptiveEncodingNames(). </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>descriptiveName</em> </td><td> the descriptive name for the encoding </td></tr> </table></dl> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> the name of the encoding </dd></dl> </p></div></div><a class="anchor" name="encodingsByScript"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname">[<a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstringlist.html">QStringList</a>] encodingsByScript</td> <td>(</td> <td class="paramtype"> </td> <td class="paramname"><em>self</em> )</td> <td width="100%"> </td> </tr> </table> </div> <div class="memdoc"><p>Lists the available encoding names grouped by script (or language that uses them). <dl class="return" compact><dt><b>Returns:</b></dt><dd> the list of lists consisting of description followed by encoding names (i.e. encodingsByScript().at(i).at(0) is a description for encodingsByScript().at(i).at(k), k>0) </dd></dl> </p></div></div><a class="anchor" name="fromEntity"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qchar.html">QChar</a> fromEntity</td> <td>(</td> <td class="paramtype"> <em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td> <td class="paramname"><em>str</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Overloaded member function. Tries to find an entity in the QString str. </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>str</em> </td><td> the string containing entified <tr><td></td><td valign="top"><em>len</em> </td><td> is a return value, that gives the length of the decoded entity. </td></tr> </table></dl> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> a decoded entity if one could be found, QChar.null otherwise </dd></dl> </p></div></div><a class="anchor" name="fromEntity"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qchar.html">QChar</a>, int len fromEntity2</td> <td>(</td> <td class="paramtype"> <em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td> <td class="paramname"><em>str</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Overloaded member function. Tries to find an entity in the QString str. </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>str</em> </td><td> the string containing entified <tr><td></td><td valign="top"><em>len</em> </td><td> is a return value, that gives the length of the decoded entity. </td></tr> </table></dl> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> a decoded entity if one could be found, QChar.null otherwise </dd></dl> </p></div></div><a class="anchor" name="languageForEncoding"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> languageForEncoding</td> <td>(</td> <td class="paramtype"> <em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td> <td class="paramname"><em>encoding</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Returns the language the encoding is used for. </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>encoding</em> </td><td> the encoding for the language </td></tr> </table></dl> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> the language of the encoding </dd></dl> <dl class="deprecated" compact><dt><b>Deprecated:</b></dt><dd> Please use descriptionForEncoding instead. This function will be removed before KDE4 is released. </dd></dl> </p></div></div><a class="anchor" name="resolveEntities"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> resolveEntities</td> <td>(</td> <td class="paramtype"> <em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> </td> <td class="paramname"><em>text</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Scans the given string for entities (like &amp;amp;) and resolves them using fromEntity. </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>text</em> </td><td> the string containing the entities </td></tr> </table></dl> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> the clean string </dd></dl> </p></div></div><a class="anchor" name="toEntity"></a> <div class="memitem"> <div class="memproto"> <table class="memname"><tr> <td class="memname"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qstring.html">QString</a> toEntity</td> <td>(</td> <td class="paramtype"> <em>self</em>, </td> <td class="paramname"></td> </tr><tr> <td class="memname"></td> <td></td> <td class="paramtype"><a href="http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qchar.html">QChar</a> </td> <td class="paramname"><em>ch</em></td> </tr> <tr> <td></td> <td>)</td> <td></td> <td></td> <td width="100%"> </td> </tr></table> </div> <div class="memdoc"><p>Converts a QChar to an entity. The returned string does already contain the leading '&' and the trailing ';'. </p><dl compact><dt><b>Parameters:</b></dt><dd> <table border="0" cellspacing="2" cellpadding="0"> <tr><td></td><td valign="top"><em>ch</em> </td><td> the char to convert </td></tr> </table></dl> <p> <dl class="return" compact><dt><b>Returns:</b></dt><dd> the entity </dd></dl> </p></div></div> </div> </div> </div> <div id="left"> <div class="menu_box"> <div class="nav_list"> <ul> <li><a href="../allclasses.html">Full Index</a></li> </ul> </div> <a name="cp-menu" /><div class="menutitle"><div> <h2 id="cp-menu-project">Modules</h2> </div></div> <div class="nav_list"> <ul><li><a href="../akonadi/index.html">akonadi</a></li> <li><a href="../dnssd/index.html">dnssd</a></li> <li><a href="../kdecore/index.html">kdecore</a></li> <li><a href="../kdeui/index.html">kdeui</a></li> <li><a href="../khtml/index.html">khtml</a></li> <li><a href="../kio/index.html">kio</a></li> <li><a href="../knewstuff/index.html">knewstuff</a></li> <li><a href="../kparts/index.html">kparts</a></li> <li><a href="../kutils/index.html">kutils</a></li> <li><a href="../nepomuk/index.html">nepomuk</a></li> <li><a href="../phonon/index.html">phonon</a></li> <li><a href="../plasma/index.html">plasma</a></li> <li><a href="../polkitqt/index.html">polkitqt</a></li> <li><a href="../solid/index.html">solid</a></li> <li><a href="../soprano/index.html">soprano</a></li> </ul></div></div> </div> </div> <div class="clearer"/> </div> <div id="end_body"></div> </div> <div id="footer"><div id="footer_text"> This documentation is maintained by <a href="mailto:simon@simonzone.com">Simon Edwards</a>.<br /> KDE<sup>®</sup> and <a href="../images/kde_gear_black.png">the K Desktop Environment<sup>®</sup> logo</a> are registered trademarks of <a href="http://ev.kde.org/" title="Homepage of the KDE non-profit Organization">KDE e.V.</a> | <a href="http://www.kde.org/contact/impressum.php">Legal</a> </div></div> </body> </html>