Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#5833 closed defect (fixed)

gdal_edit.py: problems with non-English letter setting metadata

Reported by: mj10777 Owned by: hobu
Priority: high Milestone: 2.0.0
Component: PythonBindings Version: svn-trunk
Severity: major Keywords:
Cc:

Description

As apposed to gdalwarp, gdal_edit.py will fail when using non-English letters when setting meta-data.

Adapting test_gdal_edit.py test_gdal_edit_py_1 will demonstrate the problem:

    gdal_edit_parms='tmp/test_gdal_edit_py.tif -a_srs EPSG:4326 -a_ullr 2 50 3 49 -a_nodata 123 '
    #mo_text="BAR Kniglich Academie der Wissenschaften von Jean Chrtien."
    mo_text="BAR Königlich Academie der Wissenschaften von Jean Chrétien."
    gdal_edit_parms+='-mo "FOO='
    gdal_edit_parms+=mo_text
    gdal_edit_parms+='"'
    test_py_scripts.run_py_script(script_path, 'gdal_edit', gdal_edit_parms)

...

    if md['FOO'] != mo_text:

with the '#mo_text' version it will run correctly, but with the non English characters it will fail at:

in gdal_edit
    ds.SetMetadata(md)

Change History (4)

comment:1 by Even Rouault, 9 years ago

Is your python script encoded in UTF-8 ?

comment:2 by mj10777, 9 years ago

I noticed this first when calling gdal_edit.py from a (ubuntu) terminal:

gdal_edit.py  -mo "TIFFTAG_ARTIST=mj10777.de.eu" -mo "TIFFTAG_DOCUMENTNAME=1846 Grundriss von Berlin - 1:5800" -mo 'TIFFTAG_IMAGEDESCRIPTION=Grundriss von Berlin / aufgenommen und gezeichnet mit Genehmigung der Königlich Academie der Wissenschaften von Jean Chrétien. Berlin : Schropp, 1846' 1846.Selter_Grundriss_von_Berlin.5800.3068.tif

I then tried it in the autotest script test_gdal_edit.py, which has the 'coding: utf-8' syntax in it.

Just to make sure, I ran the gdalwarp again and it ran without problem.

comment:3 by Even Rouault, 9 years ago

Resolution: fixed
Status: newclosed

trunk r28440 "Python bindings: accept Unicode strings to be passed as key and/or value of the dictionary passed to SetMetadata() (#5833)"

comment:4 by Even Rouault, 9 years ago

Milestone: 2.02.0.0

Milestone renamed

Note: See TracTickets for help on using tickets.