Replace ConvertUTF with inline SI_UTF8 conversion#97
Merged
Conversation
Remove the vendored ConvertUTF sources and implement SI_UTF8::Encode/Decode directly in SimpleIni.h so SI_CONVERT_GENERIC stays header-only. Add differential tests against the platform C library and external invalid-UTF-8 fixtures. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Apple Clang provides <uchar.h> but not c32rtomb/mbrtoc32 in C++ builds. Use iconv (UTF-32LE <-> UTF-8) as the system reference on macOS instead. Co-authored-by: Cursor <cursoragent@cursor.com>
Use \x wide-character escapes for expected Unicode values instead of UTF-8 source literals, which MSVC misinterprets without /utf-8. Enable /utf-8 for the tests target and drop emoji from the mixed fixture to avoid wchar_t UTF-16 vs UTF-32 representation differences. Co-authored-by: Cursor <cursoragent@cursor.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ConvertUTF.c/hand implement locale-independent UTF-8 conversion inline viaSI_UTF8::Encode,SI_UTF8::Decode, andSI_UTF8::REPLACEMENTinSimpleIni.hSI_CONVERT_GENERICis now truly header-only — no extra source files to compile or linkc32rtomb/mbrtoc32for all assigned Unicode scalars U+0000..U+10FFFF, plus external invalid-UTF-8 fixtures and a UTF-8 INI integration testMotivation
PR #95 proposed replacing ConvertUTF with
<uchar.h>locale-dependent APIs, which breaks under"C"locale. This keeps the dependency reduction while preserving locale-independent behavior.Test plan
ctest)Utf8Conversion.EncodeAndDecodeMatchSystemLibraryForAllAssignedScalars(~1.1M code points vs system lib)utf8-reject.hexinvalid sequences rejectedutf8-ini-roundtrip.iniload/save viaCSimpleIniWMade with Cursor