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¶
Convert bytes from files, HTTP bodies, message queues, archives, or
database exports into UTF-8 text with decode.
Convert UTF-8 application text to a required legacy byte encoding with
encode before writing or sending it.
Use getDecoder / getEncoder or transform streams when a byte
sequence may be split across network or file chunks.
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 |
|
Convert a single payload |
|
Choose between batch, stateful, and stream APIs |
|
Handle split byte sequences or stream chunks |
Chunked conversion, Stateful conversion, and Streaming conversion |
Accept encoding names from config, headers, or users |
|
Work with UTF BOMs |
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