Re: unicode conversion

seth vidal <[email protected]>
Newsgroups gmane.linux.rpm.metadata
Message-ID <1067063433.9397.105.camel@binkley>
On Sat, 2003-10-25 at 02:04, seth vidal wrote:
> 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
> 

another option occurred to me - instead of adding the note - in the
string, I could bring this function inside the RpmMetaData class and if
something triggers the above, the note is appended to that entry as an
xml comment, but still replaces the character with a '#'.

thoughts?

-sv
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.