[Qgis-developer] QgsRasterLayer.identify() returns wrongly encoded
keys?
Borys Jurgiel
borys at wolf.most.org.pl
Tue Dec 2 16:51:04 EST 2008
Hi List,
The QgsRasterLayer.identify()[1] returns such dict in Python:
{bandName:value, bandName:value, ...}
where bandName is created in line 1792 and 1836 of qgsrasterlayer.cpp:
theResults[tr( "Band" ) + QString::number( i )] = v
In Polish locale "Band" is translated to "Kanał", what contains non-ascii
character. And this character seems to be wrongly encoded. If I load a raster
layer and call from Python console, say:
sample = iface.activeLayer().identify(QgsPoint(0,0))[1]
the 'sample' contains the mentioned dictionary. Then if I try to print the
first key, which should contain QString 'Kanał 1':
print sample.keys()[0]
I give the error message:
exceptions.UnicodeEncodeError: 'ascii' codec can't encode character u'\u0142'
in position 4: ordinal not in range(128)
So the string is not properly unicoded. But I can't find any error, neither in
qgsrasterlayer.cpp nor in qgsrasterlayer.sip file. It's passed from tr()
directly to QgsRasterLayer::identify() header. Probably I'm missing something
obvious.
More information about the Qgis-developer
mailing list