lsantos2000 / feedjack

Automatically exported from code.google.com/p/feedjack
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

fix to encode function #11

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
hi Tabo..
I noticed feedjack was complaining when some of the strings were already in
UTF-8
eg...
 'Perennial Lamb\xe2\x80\x99s Ears'

this fixes that issue with a sledgehammer ;-) .. you might have a better
approach.

def encode(tstr):
    """ Encodes a unicode string in utf-8
    """
    if not tstr:
        return ''
    try:
        return tstr.encode('utf-8', "xmlcharrefreplace")
    except UnicodeDecodeError:
        # it's already UTF8.. sigh
        return tstr.decode('utf-8').encode('utf-8')

Original issue reported on code.google.com by kryton.l...@gmail.com on 25 Aug 2006 at 12:20

GoogleCodeExporter commented 8 years ago
dupe.. sorry.. google gave me an error when I submitted this.. so I email it to 
you
as well.

Original comment by kryton.l...@gmail.com on 25 Aug 2006 at 12:24

GoogleCodeExporter commented 8 years ago
Duplicate of #10

Original comment by petar.ma...@gmail.com on 22 Oct 2006 at 11:07