[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[OpenTAL-checkins] opental/pax utils.py
From: |
Fernando Lalo Martins |
Subject: |
[OpenTAL-checkins] opental/pax utils.py |
Date: |
Tue, 26 Aug 2003 17:50:25 -0400 |
CVSROOT: /cvsroot/opental
Module name: opental
Branch:
Changes by: Fernando Lalo Martins <address@hidden> 03/08/26 17:50:24
Modified files:
pax : utils.py
Log message:
adding an unicode2ascii() function that might come in handy
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/opental/opental/pax/utils.py.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
Patches:
Index: opental/pax/utils.py
diff -u opental/pax/utils.py:1.12 opental/pax/utils.py:1.13
--- opental/pax/utils.py:1.12 Mon Apr 14 18:13:02 2003
+++ opental/pax/utils.py Tue Aug 26 17:50:24 2003
@@ -4,7 +4,7 @@
from backwards_compatibility import *
from xml.sax.saxutils import escape
-import sys, types
+import sys, types, unicodedata
_replace='replace'
@@ -62,3 +62,17 @@
psyco.bind(pack_list)
except:
pass
+
+def unicode2ascii(unistr):
+ l = []
+ for c in unistr:
+ d = unicodedata.decomposition(c)
+ if d:
+ for e in d.split():
+ e = int(e, 16)
+ if 65 <= e <= 122:
+ l.append(chr(e))
+ else:
+ if ord(c) < 128:
+ l.append(str(c))
+ return ''.join(l)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [OpenTAL-checkins] opental/pax utils.py,
Fernando Lalo Martins <=