Permalink
Browse files

[ui] fix for non-ascii string data

  • Loading branch information...
1 parent ea303bd commit 5b0fbe7af48dada83f8e94c2777802101f264b42 @Eugeny Eugeny committed Oct 18, 2010
Showing with 9 additions and 2 deletions.
  1. +2 −1 ajenti/ui/classes.py
  2. +7 −1 ajenti/utils.py
@@ -1,5 +1,6 @@
import random
from lxml import etree
+from ajenti.utils import fix_unicode
class Element(etree.ElementBase):
@@ -18,7 +19,7 @@ def append(self, el):
return self
def __setitem__(self, idx, val):
- self.set(idx, unicode(str(val)))
+ self.set(idx, fix_unicode(str(val)))
def __getitem__(self, idx):
return self.get(idx)
View
@@ -11,7 +11,13 @@ def enquote(s):
return s
def fix_unicode(s):
- return s.encode('utf-8', 'xmlcharref')
+ d = ''
+ for i in range(0, len(s)):
+ if ord(s[i])<32:
+ d += ' '
+ else:
+ d += s[i]
+ return unicode(d, errors='replace')
def detect_platform():
if platform.system() != 'Linux':

0 comments on commit 5b0fbe7

Please sign in to comment.