Unicode

Anatoli Hristov tolidtm at gmail.com
Mon Dec 17 12:14:09 CET 2012


> this seems to be an encoding error of your terminal on printing.
> You may need to describe (or better post the respective parts of the
> source) where the text is coming from (external text file, database
> entry, harcoded in the python source ...), how it is stored, retrieved
> and possibly manipulated before you insert it to the database.
>
Here is how I get the data using the urllib opener:

def GetSpecsFR(icecat_prod_id):
    opener = urllib.FancyURLopener({})
    ffr = opener.open("http://prf.icecat.biz/index.cgi?product_id=%s;mi=start;smi=product;shopname=openICEcat-url;lang=fr"
% icecat_prod_id)
    specsfr = ffr.read()
    #specsfr = specsfr.decode('utf-8')
    specsfr = RemoveHTML(specsfr)
    ##specsfr = "%r" % specsfr
##    if specsfr:
##        try:
##            specsfr = str(specsfr)
##        except UnicodeEncodeError:
##            specsfr = str(specsfr.encode('utf-16'))
    return specsfr



More information about the Python-list mailing list