Repository navigation
[FEATURE] Port character encoding conversions to Rust - #2487
Aditya-Saroha wants to merge 1 commit into
Conversation
- Port get_char_in_latin_1, get_char_in_unicode, and get_char_in_utf_8 to lib_ccxr and libccxr_exports - Export cctolower and cctoupper through libccxr_exports - Hook C functions to Rust under #ifndef DISABLE_RUST - Preserve Latin-1 0x87 music note substitution as pilcrow (0xB6) for exact CI sample platform parity - Add unit tests for encodings, case mappings, and FFI pointer safety
c75398b to
1b2d7f2
Compare
CCExtractor CI platform finished running the test files on linux. 157/238 tests matched the approved output:
81 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 10124, commit 034fdbc:
Pass there, fail here:
Compared with the commit this branch was cut from: the same run as the tip of master (test 10124), so the comparison above already covers it. This branch changes the behaviour of 14 test(s) relative to the tip of master. Those are the ones worth looking at; anything else in the list fails the same way on both sides. |
CCExtractor CI platform finished running the test files on windows. 157/238 tests matched the approved output:
81 tests do not match the approved output. That is the pass/fail verdict. Whether this branch caused it is a separate question, answered below.
Compared with the tip of master — test 10125, commit 034fdbc:
Pass there, fail here:
Compared with the commit this branch was cut from: the same run as the tip of master (test 10125), so the comparison above already covers it. This branch changes the behaviour of 14 test(s) relative to the tip of master. Those are the ones worth looking at; anything else in the list fails the same way on both sides. |
[FEATURE] Port character encoding conversions to Rust
In raising this pull request, I confirm the following (please check boxes):
Reason for this PR:
Sanity check:
Repro instructions:
N/A - This PR ports existing character encoding logic from C to Rust following
docs/Rust_migration_guide.md. Unit tests verify equivalence across all 256 byte values and special character encodings.Summary
This PR ports the character encoding conversion and case-mapping functions from
src/lib_ccx/ccx_common_char_encoding.cinto pure Rust (lib_ccxr) and wires them through C-FFI exports (libccxr_exports), following the architectural conventions indocs/Rust_migration_guide.md.Functions Ported
libccxr_exports)lib_ccxr)get_char_in_latin_1(buf, c)ccxr_get_char_in_latin_1lib_ccxr::util::encoding::line21_to_latin1(c)get_char_in_unicode(buf, c)ccxr_get_char_in_unicodelib_ccxr::util::encoding::line21_to_ucs2(c)(little-endian 2-byte write)get_char_in_utf_8(buf, c)ccxr_get_char_in_utf_8lib_ccxr::util::encoding::line21_to_utf8(c)(returns length 1–3)cctolower(c)ccxr_cctolowerlib_ccxr::util::encoding::cctolower(c)cctoupper(c)ccxr_cctoupperlib_ccxr::util::encoding::cctoupper(c)Architectural Changes
lib_ccxr::util::encoding:cctolower(c: u8) -> u8andcctoupper(c: u8) -> u8public functions.Line21String,Latin1String, andUcs2Stringcasing methods to usecctolower/cctoupperdirectly. This eliminates potential panics fromchar::from_u32(c).expect(...)on unmapped/surrogate byte values.libccxr_exports::encoding:extern "C"wrappers with null-pointer guards.C Integration:
src/lib_ccx/ccx_common_char_encoding.cwith#ifndef DISABLE_RUSTdelegating toccxr_*.#elseso non-Rust builds (DISABLE_RUST) continue to compile and function without modification.Verification
lib_ccxr):cargo test --manifest-path src/rust/lib_ccxr/Cargo.toml --libVerified compilation with GCC both with Rust enabled (
gcc -c src/lib_ccx/ccx_common_char_encoding.c -Isrc/lib_ccx) and with-DDISABLE_RUST.