Sat, 04 Jun 2011 11:19:14 +0200
Fixed a few issues with the web browser.
--- a/APIs/Python3/eric5.api Thu Jun 02 20:42:01 2011 +0200 +++ b/APIs/Python3/eric5.api Sat Jun 04 11:19:14 2011 +0200 @@ -6223,6 +6223,7 @@ eric5.Utilities.configDir?7 eric5.Utilities.convertLineEnds?4(text, eol) eric5.Utilities.decode?4(text) +eric5.Utilities.decodeBytes?4(buffer) eric5.Utilities.decodeString?4(text) eric5.Utilities.direntries?4(path, filesonly=False, pattern=None, followsymlinks=True, checkStop=None) eric5.Utilities.encode?4(text, orig_coding)
--- a/Documentation/Help/source.qhp Thu Jun 02 20:42:01 2011 +0200 +++ b/Documentation/Help/source.qhp Sat Jun 04 11:19:14 2011 +0200 @@ -2354,6 +2354,7 @@ <keyword name="compile" id="compile" ref="eric5.Utilities.__init__.html#compile" /> <keyword name="convertLineEnds" id="convertLineEnds" ref="eric5.Utilities.__init__.html#convertLineEnds" /> <keyword name="decode" id="decode" ref="eric5.Utilities.__init__.html#decode" /> + <keyword name="decodeBytes" id="decodeBytes" ref="eric5.Utilities.__init__.html#decodeBytes" /> <keyword name="decodeString" id="decodeString" ref="eric5.Utilities.__init__.html#decodeString" /> <keyword name="direntries" id="direntries" ref="eric5.Utilities.__init__.html#direntries" /> <keyword name="encode" id="encode" ref="eric5.Utilities.__init__.html#encode" />
--- a/Documentation/Source/eric5.Utilities.__init__.html Thu Jun 02 20:42:01 2011 +0200 +++ b/Documentation/Source/eric5.Utilities.__init__.html Sat Jun 04 11:19:14 2011 +0200 @@ -59,6 +59,9 @@ <td><a href="#decode">decode</a></td> <td>Function to decode some byte text into a string.</td> </tr><tr> +<td><a href="#decodeBytes">decodeBytes</a></td> +<td>Function to decode some byte text into a string.</td> +</tr><tr> <td><a href="#decodeString">decodeString</a></td> <td>Function to decode a string containing Unicode encoded characters.</td> </tr><tr> @@ -426,6 +429,24 @@ </dl> <div align="right"><a href="#top">Up</a></div> <hr /><hr /> +<a NAME="decodeBytes" ID="decodeBytes"></a> +<h2>decodeBytes</h2> +<b>decodeBytes</b>(<i>buffer</i>) +<p> + Function to decode some byte text into a string. +</p><dl> +<dt><i>buffer</i></dt> +<dd> +byte buffer to decode (bytes) +</dd> +</dl><dl> +<dt>Returns:</dt> +<dd> +decoded text (string) +</dd> +</dl> +<div align="right"><a href="#top">Up</a></div> +<hr /><hr /> <a NAME="decodeString" ID="decodeString"></a> <h2>decodeString</h2> <b>decodeString</b>(<i>text</i>)
--- a/Helpviewer/OpenSearch/OpenSearchEngine.py Thu Jun 02 20:42:01 2011 +0200 +++ b/Helpviewer/OpenSearch/OpenSearchEngine.py Sat Jun 04 11:19:14 2011 +0200 @@ -442,7 +442,7 @@ Private slot to receive the suggestions. """ buffer = bytes(self.__suggestionsReply.readAll()) - response = Utilities.decode(buffer)[0] + response = Utilities.decodeBytes(buffer) response = response.strip() self.__suggestionsReply.close()
--- a/Preferences/ConfigurationDialog.py Thu Jun 02 20:42:01 2011 +0200 +++ b/Preferences/ConfigurationDialog.py Sat Jun 04 11:19:14 2011 +0200 @@ -287,6 +287,9 @@ "networkPage" : \ [self.trUtf8("Network"), "preferences-network.png", "NetworkPage", None, None], + "printerPage" : \ + [self.trUtf8("Printer"), "preferences-printer.png", + "PrinterPage", None, None], "pythonPage" : \ [self.trUtf8("Python"), "preferences-python.png", "PythonPage", None, None],
--- a/Preferences/ConfigurationPages/HelpWebBrowserPage.py Thu Jun 02 20:42:01 2011 +0200 +++ b/Preferences/ConfigurationPages/HelpWebBrowserPage.py Sat Jun 04 11:19:14 2011 +0200 @@ -91,8 +91,9 @@ self.homePageEdit.setText( Preferences.getHelp("HomePage")) - self.defaultSchemeCombo.setEditText( - Preferences.getHelp("DefaultScheme")) + self.defaultSchemeCombo.setCurrentIndex( + self.defaultSchemeCombo.findText( + Preferences.getHelp("DefaultScheme"))) historyLimit = Preferences.getHelp("HistoryLimit") idx = 0
--- a/Utilities/__init__.py Thu Jun 02 20:42:01 2011 +0200 +++ b/Utilities/__init__.py Sat Jun 04 11:19:14 2011 +0200 @@ -321,26 +321,48 @@ buf += bytes(text[index], encoding="ascii") index += 1 buf = buf.replace(b"\x00", b"") + return decodeBytes(buf) + +def decodeBytes(buffer): + """ + Function to decode some byte text into a string. + + @param buffer byte buffer to decode (bytes) + @return decoded text (string) + """ + # try UTF with BOM + try: + if buffer.startswith(BOM_UTF8): + # UTF-8 with BOM + return str(buffer[len(BOM_UTF8):], encoding='utf-8') + elif buffer.startswith(BOM_UTF16): + # UTF-16 with BOM + return str(buffer[len(BOM_UTF16):], encoding='utf-16') + elif buffer.startswith(BOM_UTF32): + # UTF-32 with BOM + return str(buffer[len(BOM_UTF32):], encoding='utf-32') + except (UnicodeError, LookupError): + pass # try UTF-8 try: - return str(buf, encoding="utf-8") + return str(buffer, encoding="utf-8") except UnicodeError: pass # try codec detection try: import ThirdParty.CharDet.chardet - guess = ThirdParty.CharDet.chardet.detect(buf) + guess = ThirdParty.CharDet.chardet.detect(buffer) if guess and guess['encoding'] is not None: codec = guess['encoding'].lower() - return str(buf, codec) + return str(buffer, encoding=codec) except (UnicodeError, LookupError): pass except ImportError: pass - return str(text, "utf-8", "ignore") + return str(buffer, encoding="utf-8", errors="ignore") _escape = re.compile("[&<>\"\u0080-\uffff]")