Utilities/__init__.py

changeset 2084
d3f083dd0222
parent 2079
febae63bb821
child 2085
b4c1f0b6dac2
--- a/Utilities/__init__.py	Mon Oct 01 19:43:54 2012 +0200
+++ b/Utilities/__init__.py	Mon Oct 01 19:44:40 2012 +0200
@@ -373,6 +373,20 @@
     
     return str(buffer, encoding="utf-8", errors="ignore")
 
+
+def readStringFromStream(stream):
+    """
+    Module function to read a string from the given stream.
+    
+    @param stream data stream opened for reading (QDataStream)
+    @return string read from the stream (string)
+    """
+    data = stream.readString()
+    if data is None:
+        data = b""
+    return data.decode()
+
+
 _escape = re.compile("[&<>\"'\u0080-\uffff]")
 
 _escape_map = {

eric ide

mercurial