unicode conversion
seth vidal <[email protected]>
| Newsgroups | gmane.linux.rpm.metadata |
|---|---|
| Message-ID | <1067061864.9397.102.camel@binkley> |
hi all,
this is what I did, comments?
def utf8String(string):
"""hands back a unicoded string"""
try:
string = unicode(string)
except UnicodeError, e:
newstring = ''
for char in string:
if ord(char) > 127:
newstring = newstring + '#'
else:
newstring = newstring + char
newstring = newstring + 'NOTE: Characters replaced outside of UTF8 Range'
return unicode(newstring)
else:
return string
-sv