瀏覽代碼

wxGUI/dbmgr: rewrite unicodeValue()

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@54252 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 12 年之前
父節點
當前提交
5dd8d59028
共有 1 個文件被更改,包括 5 次插入16 次删除
  1. 5 16
      gui/wxpython/dbmgr/vinfo.py

+ 5 - 16
gui/wxpython/dbmgr/vinfo.py

@@ -31,24 +31,13 @@ def unicodeValue(value):
         return value
     
     enc = UserSettings.Get(group = 'atm', key = 'encoding', subkey = 'value')
-    if enc:
-        try:
-            value = unicode(value, enc)
-        except LookupError, e:
-            value = e
-    elif 'GRASS_DB_ENCODING' in os.environ:
-        try:
-            value = unicode(value, os.environ['GRASS_DB_ENCODING'])
-        except LookupError, e:
-            value = e
+    if not enc and 'GRASS_DB_ENCODING' in os.environ:
+        enc = os.environ['GRASS_DB_ENCODING']
     else:
-        try:
-            value = unicode(value, 'ascii')
-        except UnicodeDecodeError:
-            value = _("Unable to decode value. Set encoding in GUI preferences ('Attributes').")
+        enc = 'ascii'
+    
+    return unicode(value, enc, errors = 'replace')
     
-    return value
-
 def createDbInfoDesc(panel, mapDBInfo, layer):
     """!Create database connection information content"""
     infoFlexSizer = wx.FlexGridSizer (cols = 2, hgap = 1, vgap = 1)