Opened 13 years ago

Closed 6 years ago

#3833 closed defect (fixed)

libkml locale support

Reported by: bishop Owned by: warmerdam
Priority: normal Milestone:
Component: default Version: svn-trunk
Severity: normal Keywords:
Cc:

Description (last modified by bishop)

While creating kml file using lib kml, if file name, fields names and data used locale strings, the output file is wrong: if I convert locale strings to UTF-8 - the data inside file correct, but file name is wrong (path is unreadable by most of programmes); if I don't convert locale strings to UTF-8 - the data inside file is not correct, but file name is right. The kmz file in most cases is unreadable (the Google Earth open such a file but it is empty).

Attachments (2)

тест_файл.kml (201 bytes ) - added by bishop 11 years ago.
valid name and invalid layer name
ge_screenshoot.png (7.9 KB ) - added by bishop 11 years ago.
The Google Erath screen with valid and invalid data

Download all attachments as: .zip

Change History (6)

comment:1 by bishop, 13 years ago

Description: modified (diff)

in reply to:  1 comment:2 by winkey, 11 years ago

bishop

can you provide examples of this?

brian

comment:3 by bishop, 11 years ago

This is simple code. Path, layer and field name is UTF8 encoded russian text "тест_файл", "тест_слой" and "тест_поле". After GDAL shifted to UTF in file names, this code generate valid kml, but kmz is not valid.

#include "ogrsf_frmts.h"

int main()
{
    const char *pszDriverName = "LIBKML";
    OGRSFDriver *poDriver;

    OGRRegisterAll();

    poDriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(
                pszDriverName );
    if( poDriver == NULL )
    {
        printf( "%s driver not available.\n", pszDriverName );
        exit( 1 );
    }

    OGRDataSource *poDS;

    CPLString sName("d://temp//тест_файл.kmz");
    poDS = poDriver->CreateDataSource( sName, NULL );
    if( poDS == NULL )
    {
        printf( "Creation of output file failed.\n" );
        exit( 1 );
    }

    OGRLayer *poLayer;

    poLayer = poDS->CreateLayer( "тест_слой", NULL, wkbPoint, NULL );
    if( poLayer == NULL )
    {
        printf( "Layer creation failed.\n" );
        exit( 1 );
    }

    OGRFieldDefn oField( "тест_поле", OFTString );

    oField.SetWidth(32);

    if( poLayer->CreateField( &oField ) != OGRERR_NONE )
    {
        printf( "Creating Name field failed.\n" );
        exit( 1 );
    }

    OGRDataSource::DestroyDataSource( poDS );
}

Also, simple command

set GDAL_FILENAME_IS_UTF8=OFF
ogr2ogr -f LIBKML -nln тест_слой d:\temp\тест_Файл.kml D:\work\testgeodata\shp\test.shp

generate invalid kml with valid name, and if GDAL_FILENAME_IS_UTF8=ON - everything is invalid.

It seems to me that libkml driver generate ASCII encoded files, but most software expected UTF8 encoded kml.

by bishop, 11 years ago

Attachment: тест_файл.kml added

valid name and invalid layer name

by bishop, 11 years ago

Attachment: ge_screenshoot.png added

The Google Erath screen with valid and invalid data

comment:4 by Even Rouault, 6 years ago

Resolution: fixed
Status: newclosed

I guess there shouldn't any issue anymore if GDAL is properly used (ie filenames and content set to UTF-8)

Note: See TracTickets for help on using tickets.