1

I need to import some shapefiles into a database. PostGIS has successfully imported several small files.

enter image description here

But an error occurred with large files. It shows this error: "Unable to convert data value to UTF-8 (iconv reports "Invalid argument"). Current encoding is "UTF-8". Try "LATIN1" (Western European), or one of the values described at http://www.postgresql.org/docs/current/static/multibyte.html."

PostGIS recommended changing the encodings from UTF-8 to latin1. Thus, the import occurred, but Cyrillic names in the database are displayed incorrectly.

enter image description here

How can I fix this?

Sergey47
  • 53
  • 5
  • 1
    What is the error message? How are you importing, ogr2ogr, shp2pgsql? – BERA Mar 09 '23 at 12:46
  • Have the small files also had UTF8 encoding and does it import correctly? – til_b Mar 09 '23 at 12:46
  • This is more of a dBase encoding and internationalization issue than a PostGIS one. Details about the shapefile contents and the exact error are necessary. – Vince Mar 09 '23 at 12:46
  • 1
    Unable to convert data value to UTF-8 (iconv reports "Invalid argument"). Current encoding is "UTF-8". Try "LATIN1" (Western European), or one of the values described at http://www.postgresql.org/docs/current/static/multibyte.html – Sergey47 Mar 09 '23 at 12:50
  • 1
    Small files are also in UTF-8 and cyrilic names in db are correct – Sergey47 Mar 09 '23 at 12:51
  • Please [Edit] the Question in response to requests for clarification. – Vince Mar 09 '23 at 14:58
  • Error messages should always be in the Question as text, making them legible on all devices and searchable by others. – Vince Mar 09 '23 at 16:08

1 Answers1

1

You need to find the correct encoding of your original shapefile.

Take a look here: https://gis.stackexchange.com/a/3663/120505

It's supposed to be latin1 but some programs use *.cpg files to store encoding info, so try to look at those files.

You can also open it in ArcGIS or QGIS, check if the encoding is really correct or if this is a problem with your file, and try to resave it.

robin loche
  • 2,465
  • 5
  • 9
  • UTF 8 is written in cpg files. But dbf has a different encoding and in the case of small files, it converts to UTF 8, if a file with a large number of lines, it gives the error that it described earlier – Sergey47 Mar 09 '23 at 15:26
  • Have you tried SELECT convert(name, 'LATIN1', 'UTF8') from my_table ? – robin loche Mar 09 '23 at 15:43
  • If the codepage file claims UTF-8, but it isn't, the file may not be usable. It's not nice to lie to ETL software. – Vince Mar 09 '23 at 16:11
  • Vince, but it works with other files. I have converted these files to QGIS, and they are displayed correctly there – Sergey47 Mar 09 '23 at 16:21