Opened 21 months ago

Closed 21 months ago

Last modified 21 months ago

#7142 closed defect (fixed)

ogr2ogr Windows command line encoding of special characters issue

Reported by: hansw Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords: character encoding attributes windows command line
Cc:

Description

Hello,

I'm using GDAL 2.3.0dev, (compiled: November 08 2017) under Windows 7 x64. ​Source

I'm trying to rename an attribute to an attribute name with a special character (umlaut). This Character is part of the ANSI character encoding.

This is the windows batch command I tried. (test.sqlite is attached to the ticket)

CMD /c ogr2ogr.exe -f "GPKG" "C:\result.gpkg" "C:\test.sqlite" -sql "SELECT \"ogc_fid\", \"test\", \"laenge\" AS \"länge\", \"geometry\" FROM \"test\";"

It works fine except that it does not rename the attribute correctly. The result can be seen in the first attached picture (result.png). The expected result can be seen in the second attached picture (expected_result.png).

So I tried to set the windows command to Unicode (UCS-2 le) with the "/U" option (see).

CMD /U /c ogr2ogr.exe -f "GPKG" "C:\result.gpkg" "C:\test.sqlite" -sql "SELECT \"ogc_fid\", \"test\", \"laenge\" AS \"länge\", \"geometry\" FROM \"test\";"

This did not work either. So I tried an easy test case:

CMD /c Echo This is a test öäüßÖÄÜ > "C:\test.txt"

This does give me a text file with the expected text:

This is a test öäüßÖÄÜ 

As this tells me that encoding of this special characters works fine on my system. I would like to ask if that could be a GDAL Windows issue. And if possible if it can be fixed.

Another related issue could be the Ticket 6447.

Attachments (3)

test.sqlite (130.0 KB) - added by hansw 21 months ago.
test file
result.png (4.2 KB) - added by hansw 21 months ago.
result
expected_result.png (3.6 KB) - added by hansw 21 months ago.
expected result

Download all attachments as: .zip

Change History (5)

Changed 21 months ago by hansw

Attachment: test.sqlite added

test file

Changed 21 months ago by hansw

Attachment: result.png added

result

Changed 21 months ago by hansw

Attachment: expected_result.png added

expected result

comment:1 Changed 21 months ago by Even Rouault

Milestone: 2.3.0
Resolution: duplicate
Status: newclosed

Yes this is a general issue with command line utilities on Windows and non-ASCII characters. GDAL utilities should probably use the Unicode Windows API to get the command line values

Closing as duplicate of #7065

comment:2 Changed 21 months ago by Even Rouault

Resolution: duplicatefixed

In 40693:

Command line utilities: use Unicode main on Windows to avoid issues with non-ASCII characters (fixes #7065, fixes #7142)

Note: See TracTickets for help on using tickets.