Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
write field names in the same encoding as attribute values (fix #4540)
  • Loading branch information
minorua committed May 5, 2013
1 parent d3f9dd5 commit 788e429
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/providers/ogr/qgsogrprovider.cpp
Expand Up @@ -913,7 +913,7 @@ bool QgsOgrProvider::addAttributes( const QList<QgsField> &attributes )
continue;
}

OGRFieldDefnH fielddefn = OGR_Fld_Create( TO8( iter->name() ), type );
OGRFieldDefnH fielddefn = OGR_Fld_Create( mEncoding->fromUnicode( iter->name() ).constData(), type );
OGR_Fld_SetWidth( fielddefn, iter->length() );
OGR_Fld_SetPrecision( fielddefn, iter->precision() );

Expand Down Expand Up @@ -1893,7 +1893,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
if ( precision < 0 )
precision = 3;

field = OGR_Fld_Create( TO8( it->first ), OFTReal );
field = OGR_Fld_Create( codec->fromUnicode( it->first ).constData(), OFTReal );
OGR_Fld_SetWidth( field, width );
OGR_Fld_SetPrecision( field, precision );
}
Expand All @@ -1902,7 +1902,7 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
if ( width < 0 || width > 10 )
width = 10;

field = OGR_Fld_Create( TO8( it->first ), OFTInteger );
field = OGR_Fld_Create( codec->fromUnicode( it->first ).constData(), OFTInteger );
// limit to 10. otherwise OGR sets it to 11 and recognizes as OFTDouble later
OGR_Fld_SetWidth( field, width );
}
Expand All @@ -1911,16 +1911,16 @@ QGISEXTERN bool createEmptyDataSource( const QString &uri,
if ( width < 0 || width > 255 )
width = 255;

field = OGR_Fld_Create( TO8( it->first ), OFTString );
field = OGR_Fld_Create( codec->fromUnicode( it->first ).constData(), OFTString );
OGR_Fld_SetWidth( field, width );
}
else if ( fields[0] == "Date" )
{
field = OGR_Fld_Create( TO8( it->first ), OFTDate );
field = OGR_Fld_Create( codec->fromUnicode( it->first ).constData(), OFTDate );
}
else if ( fields[0] == "DateTime" )
{
field = OGR_Fld_Create( TO8( it->first ), OFTDateTime );
field = OGR_Fld_Create( codec->fromUnicode( it->first ).constData(), OFTDateTime );
}
else
{
Expand Down

0 comments on commit 788e429

Please sign in to comment.