Replace the generated C++ legacy codec implementations with a small Rust wrapper around encoding_rs. This keeps the existing LibTextCodec API while moving label lookup, legacy decode/encode, validation, and streaming decoder state to Rust. The generated index data and generator are no longer needed. It also fixes several TextDecoder EOF cases due to a more correct implementation. encoding_rs finalizes decoders according to the Encoding Standard, so incomplete UTF-8/Big5 tails and malformed UTF-16 surrogate tails produce the required single replacement at end-of-queue instead of being dropped, buffered, or double-counted by our old hand-written decoders.
13 lines
530 B
CMake
13 lines
530 B
CMake
set(SOURCES
|
|
Decoder.cpp
|
|
Encoder.cpp
|
|
)
|
|
|
|
ladybird_lib(LibTextCodec textcodec EXPLICIT_SYMBOL_EXPORT)
|
|
|
|
import_rust_crate(MANIFEST_PATH Rust/Cargo.toml CRATE_NAME libtextcodec_rust FFI_HEADER RustFFI.h)
|
|
target_link_libraries(LibTextCodec PRIVATE libtextcodec_rust)
|
|
|
|
get_target_property(_libtextcodec_rust_lib libtextcodec_rust IMPORTED_LOCATION)
|
|
set_property(SOURCE Decoder.cpp APPEND PROPERTY OBJECT_DEPENDS ${_libtextcodec_rust_lib})
|
|
set_property(SOURCE Encoder.cpp APPEND PROPERTY OBJECT_DEPENDS ${_libtextcodec_rust_lib})
|