Skip to content
Permalink
Browse files

write field names in the same encoding as attribute values (fix #4540)

  • Loading branch information
minorua committed May 5, 2013
1 parent d3f9dd5 commit 788e4294267913b8b1ae6211c0e9639a1c290a74
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/providers/ogr/qgsogrprovider.cpp
@@ -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() );

@@ -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 );
}
@@ -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 );
}
@@ -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
{

0 comments on commit 788e429

Please sign in to comment.
You can’t perform that action at this time.