[Qgis-developer] python unicode problem in raster metadata

Carson Farmer carson.farmer at gmail.com
Wed Jan 28 19:07:33 EST 2009


Hi Volkan,
>>> layer.metadata()
>>>       
>
> sys.displayhook = sys.__displayhook__
>
> UnicodeEncodeError: 'ascii' codec can't encode character u'\xfc' in
> position 19: ordinal not in range(128)
>   
Because the metadata contains Turkish characters (which aren't ascii), 
it throws a unicode encode error when you try to print it. But if you 
assign the metadata to a variable, then you could probably convert to 
string yourself, or let python do it for you:

meta_data = layer.metadata()

example:
 >>> test = "è"
 >>> test
'\xc3\xa8'


Hopefully that helps a bit?

Carson


More information about the Qgis-developer mailing list