From: Paul Ramsey Date: Fri, 18 Mar 2011 19:13:26 +0000 (+0000) Subject: Jeff Adams: Added regression test for LATIN1 encoding, fixed failure to convert to... X-Git-Tag: 2.0.0alpha1~1870 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9b394f152f4f0cebea9575547ec232285e66566f;p=postgis Jeff Adams: Added regression test for LATIN1 encoding, fixed failure to convert to UTF8. (#808) git-svn-id: http://svn.osgeo.org/postgis/trunk@6932 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/loader/shp2pgsql-core.c b/loader/shp2pgsql-core.c index 84c4e48cf..7a22d9f63 100644 --- a/loader/shp2pgsql-core.c +++ b/loader/shp2pgsql-core.c @@ -1557,6 +1557,7 @@ ShpLoaderGenerateSQLRowStatement(SHPLOADERSTATE *state, int item, char **strreco return SHPLOADERERR; } + strncpy(val, utf8str, MAXVALUELEN); } /* Escape attribute correctly according to dump format */ diff --git a/regress/Makefile.in b/regress/Makefile.in index eea28f994..37be67516 100644 --- a/regress/Makefile.in +++ b/regress/Makefile.in @@ -46,6 +46,7 @@ TESTS = \ loader/MultiToSinglePoint \ loader/ReprojectPts \ loader/ReprojectPtsGeog \ + loader/Latin1 \ regress \ regress_index \ regress_index_nulls \ diff --git a/regress/loader/Latin1.dbf b/regress/loader/Latin1.dbf new file mode 100644 index 000000000..bdee7f781 Binary files /dev/null and b/regress/loader/Latin1.dbf differ diff --git a/regress/loader/Latin1.opts b/regress/loader/Latin1.opts new file mode 100644 index 000000000..478a5b724 --- /dev/null +++ b/regress/loader/Latin1.opts @@ -0,0 +1,2 @@ +# The DBF contains a string with Norweigan characters. +-W LATIN1 diff --git a/regress/loader/Latin1.select.expected b/regress/loader/Latin1.select.expected new file mode 100644 index 000000000..3f9b46216 --- /dev/null +++ b/regress/loader/Latin1.select.expected @@ -0,0 +1 @@ +1|Tårneby in Våler I Solør kommune diff --git a/regress/loader/Latin1.select.sql b/regress/loader/Latin1.select.sql new file mode 100644 index 000000000..663dc296f --- /dev/null +++ b/regress/loader/Latin1.select.sql @@ -0,0 +1 @@ +SELECT * FROM loadedshp; diff --git a/regress/loader/README b/regress/loader/README index 4b9ae6de0..f515b4f22 100644 --- a/regress/loader/README +++ b/regress/loader/README @@ -1,10 +1,13 @@ -A loader test requires, at a minimum, a shapefile: +A loader test requires, at a minimum, a dbf file: + +.dbf + +Most tests will use a shapefile, so these files as well: .shp .shx -.dbf -The loader will be run against the shapefile with no command-line flags, +The loader will be run against the dbf/shapefile with no command-line flags, then the output will be run via psql to insert the table into PostGIS. If there is no .opts file, the loader is then run with the -D flag, diff --git a/regress/run_test b/regress/run_test index f0ea44385..db1e084dc 100755 --- a/regress/run_test +++ b/regress/run_test @@ -570,9 +570,11 @@ while [ -n "$1" ]; do fi fi - # Check .shp *before* .sql as loader test could + # Check .dbf *before* .sql as loader test could # create the .sql - if [ -r "${TEST}.shp" ]; then + # Check for .dbf not just .shp since the loader can load + # .dbf files without a .shp. + if [ -r "${TEST}.dbf" ]; then if run_loader_test; then echo " ok" fi