feat(utf8): internal_encoding flag + route format_text (A1, #3681) - #3683
Merged
kvirund merged 1 commit intoAug 3, 2026
Merged
Conversation
#3681) Track A1 of the KOI8-R -> UTF-8 migration. Introduces the build-time `internal_encoding` switch and a native-encoding dispatch layer, then routes the text reformatter through it. No behaviour change on the default KOI8-R build (char_count == byte count, capitalize_first == UPPER of the first byte, truncate_offset == maxlen); the utf8 build gets code-point semantics. - meson_options.txt / meson.build: internal_encoding=koi8r|utf8, the utf8 value defines INTERNAL_ENCODING_UTF8. - src/utils/native_text.{h,cpp}: char_count / capitalize_first / truncate_offset with a byte-identical KOI8-R branch and a utf8:: branch, plus native_is_utf8(). - src/utils/utils.cpp: format_text() width accounting, first-letter capitalisation and maxlen truncation no longer assume 1 byte == 1 character. - tests/native_text.cpp: adaptive GTest suite branching on native_is_utf8().
19 tasks
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.
Трек A1 «Плана Наполеон» (#3681): вводим переключатель кодировки и слой-диспетчер, прогоняем через него переформатер текста. Поведение на дефолтной KOI8-R-сборке не меняется (
char_count == flow-start,capitalize_first == UPPER(*pos),truncate_offset == maxlen) — это no-op-рефактор, который «оживёт» только при флипе кодировки.Что внутри
meson_options.txt/meson.build— опцияinternal_encoding(koi8rпо умолчанию /utf8); значениеutf8определяет-DINTERNAL_ENCODING_UTF8.src/utils/native_text.{h,cpp}— операции в нативной рантайм-кодировке:char_count,capitalize_first,truncate_offset. Две ветки за макросом: KOI8-R — байт-в-байт как раньше; UTF-8 — черезutf8::. Плюсnative_is_utf8(), чтобы тесты/вызывающий код могли ветвиться по флагу, с которым собрана библиотека.src/utils/utils.cpp—format_text(): счёт ширины строки, заглавная первая буква слова и обрезка поmaxlenбольше не предполагают «1 байт = 1 символ».tests/native_text.cpp— адаптивный GTest-набор (ветвится поnative_is_utf8()), поэтому один файл корректен и под KOI8-R, и под UTF-8 сборку.Проверка
native_text+ утилиты прогнал автономно с-DINTERNAL_ENCODING_UTF8— 5/5 зелёные, чисто под-Wall -Wextra.native_is_utf8()==false).Патч-бамп
VERSION.txt→0.1.28.