Skip to content
Novus Examples
cpg6 B

Shapefile — Code Page Sidecar (.cpg, UTF-8)

A one-line sidecar naming the encoding of the .dbf. Without it a reader has to guess — usually cp1252 — and every non-ASCII attribute value comes back as mojibake, which is the single most common shapefile data-loss bug.

Preview — first 2 linescpg
UTF-8

Specifications

Format
Esri shapefile component
Crs
WGS 84 (EPSG:4326)
Byte Order
mixed — big-endian headers, little-endian records
Sidecar Set
.shp/.shx/.dbf/.prj/.cpg
Content
UTF-8
Purpose
declares the .dbf character encoding
Line Endings
LF

Testing contract

Expected to pass
Scenario
Read the attribute table with and without honouring the .cpg declaration.
Expected result
With the sidecar the DBF is decoded as UTF-8; without it a reader falling back to cp1252 mis-decodes any multi-byte character.

What is a .cpg file?

A .cpg file is a one-line sidecar naming the character encoding used by a shapefile's .dbf attribute table — typically UTF-8, or a legacy code page such as ISO-8859-1 or CP1252. The dBase format has no reliable in-band encoding declaration, so without this file a reader has to guess, and non-ASCII attribute values come back as mojibake.

How to use this file

Use an example .cpg file to test shapefile readers' encoding handling, confirming that the declared code page is applied to .dbf string fields and that a missing or contradictory .cpg is reported rather than silently guessed.

How to use this file for testing

“Shapefile — Code Page Sidecar (.cpg, UTF-8)” is a deterministic Novus Examples fixture for Geospatial, Encoding detection, Metadata testing. GeoJSON, GPX, and KML files with points, lines, polygons, and tracks — for testing map tools, route parsers, and geo importers.

Documented properties for this file: LF · Esri shapefile component. Compare results against paired or grouped companions on this page when present (clean↔damaged, searchable↔scanned, or format twins) so scores stay reproducible across runs.

Download the file once, keep the path stable in CI or local scripts, and treat the spec table as the contract: dimensions, seeds, field lists, and roles are intentional. Corrupt or invalid samples are labelled as such — expect parsers to fail loudly rather than silently accept them.

Geospatial fixtures publish one invented territory across formats, with the coordinate reference system and feature counts documented in specs. Convert or reproject and diff against the twin in the same group; edge-case geometries state exactly which assumption they are built to break.

Generated by generation/geospatial.py. Free for any use, no attribution required — license.