7

I would like to write a script that includes a selection from the attribute table. But my data is in Hungarian, so it includes special characters like: öüőűáéí

So when there is non of these in the query it executes, otherwise I get this:

Is there a setting or something to solve this?

whyzar
  • 12,053
  • 23
  • 38
  • 72
buboreka
  • 396
  • 2
  • 13

1 Answers1

2

What happens when you use diacritic characters?

It might be a simple python problem. Open the python editor in QGIS, and ensure that you start with the two comment lines on the top, like this:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
layers = QgsMapLayerRegistry.instance().mapLayersByName('utilizador') 
layer = layers[0]
it = layer.getFeatures()

layer.startEditing()
for feat in it:
  layer.changeAttributeValue(feat.id(), 7, u'Jó napot kívánok!')

layer.commitChanges()
jgrocha
  • 5,345
  • 25
  • 43
  • #!/usr/bin/env python

    -- coding: ISO-8859-2 --

    name = "Algyő" print name

    I did this in the console, but the result is still AlgyÅ

    – buboreka Nov 30 '16 at 13:56
  • 2
    UTF-8 encoding is also good for Hungarian characters. The ISO-8859-2 is much older. You must know which of these two you are using. – jgrocha Nov 30 '16 at 15:07
  • Well, as my ESRI shape is in utf-8 I started with that, than I give the ISO-8859-2 a try, but also did not help. But anyways, what really bothers me is that if I run that little code (also with utf-8) in any consoles it works but not here in qgis. – buboreka Nov 30 '16 at 15:20
  • 1
    Did you try to prefix the strings with a u? u'Jó napot kívánok!' – Matthias Kuhn Nov 30 '16 at 15:46
  • with the prefix it works in the console thank you! However I still have to find out how to use this in processing algorithm – buboreka Nov 30 '16 at 16:01