iconv-lite

C++ companion port of npm iconv-lite for polycpp applications that need to accept, produce, or relay text in legacy byte encodings while keeping their C++ domain model in UTF-8.

#include <polycpp/iconv_lite/iconv_lite.hpp>

Use this library when a protocol, file, database export, mail body, terminal integration, or partner system says “this text is Windows-1251”, “Shift_JIS”, gb18030, latin1, utf16le, or another iconv-lite-style label, but your application code wants normal UTF-8 std::string values.

Common workflows

Decode an incoming payload

Convert bytes from files, HTTP bodies, message queues, archives, or database exports into UTF-8 text with decode.

Encode for a legacy system

Convert UTF-8 application text to a required legacy byte encoding with encode before writing or sending it.

Process chunked data

Use getDecoder / getEncoder or transform streams when a byte sequence may be split across network or file chunks.

Normalize labels and BOMs

Accept user-provided labels safely, inspect how they resolve, and control BOM stripping or prepending for UTF encodings.

Where to go next

If you need to…

Read…

Add the dependency to a CMake project

Installation

Convert a single payload

Quickstart and Batch conversion

Choose between batch, stateful, and stream APIs

Choosing a conversion workflow

Handle split byte sequences or stream chunks

Chunked conversion, Stateful conversion, and Streaming conversion

Accept encoding names from config, headers, or users

Encoding labels and Handling untrusted labels

Work with UTF BOMs

BOM handling and BOM-sensitive payloads

Getting started

FetchContent_Declare(
    polycpp_iconv_lite
    GIT_REPOSITORY https://github.com/polycpp/iconv-lite.git
    GIT_TAG        master
)
FetchContent_MakeAvailable(polycpp_iconv_lite)
target_link_libraries(my_app PRIVATE polycpp::iconv_lite)

Installation | Quickstart | Examples | How-to guides | API reference