diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-06-25 14:39:00 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-06-25 23:47:47 +0900 |
| commit | d0336078c5b63b174e7313d54d973a1832228928 (patch) | |
| tree | b0ed23c382e7ffd854fd3afb266a6932002e3335 /crates/shirabe-external-packages/src/symfony/string/unicode_string.rs | |
| parent | eebba7ebad103a2f7afe885a25ba2e96efddbd89 (diff) | |
| download | php-shirabe-d0336078c5b63b174e7313d54d973a1832228928.tar.gz php-shirabe-d0336078c5b63b174e7313d54d973a1832228928.tar.zst php-shirabe-d0336078c5b63b174e7313d54d973a1832228928.zip | |
feat(external-packages,shim): implement impl todos across components
Port seld/jsonlint JsonParser (+hand-written Lexer), unblocking 10 json_file
parse-error tests verified byte-for-byte against PHP. Implement Symfony Finder
SplFileInfo, executable finders, String classes (byte/code-point/unicode),
ZipArchive shim (via the zip crate), SPDX license validation, and shim
date/stream functions. Genuinely-blocked sites (reflection, PHP runtime
constants, non-UTF-8 transcoding, recursive PCRE) stay todo!() with reasons.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/string/unicode_string.rs')
| -rw-r--r-- | crates/shirabe-external-packages/src/symfony/string/unicode_string.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/string/unicode_string.rs b/crates/shirabe-external-packages/src/symfony/string/unicode_string.rs index 8917f20..e415846 100644 --- a/crates/shirabe-external-packages/src/symfony/string/unicode_string.rs +++ b/crates/shirabe-external-packages/src/symfony/string/unicode_string.rs @@ -34,11 +34,23 @@ impl UnicodeString { width } + // TODO(phase-d): the faithful `length()` uses `grapheme_strlen` (extended grapheme clusters), + // which needs Unicode segmentation tables with no Rust std equivalent and no permitted crate. + // Approximated with the code-point count, exact only when no combining/multi-code-point + // clusters are present (e.g. ASCII). pub fn length(&self) -> i64 { - todo!() + shirabe_php_shim::mb_strlen(&self.string, "UTF-8") } - pub fn slice(&self, _start: i64, _length: Option<i64>) -> Self { - todo!() + // TODO(phase-d): the faithful `slice()` uses `grapheme_substr` (grapheme-cluster offsets), which + // needs Unicode segmentation tables with no std equivalent and no permitted crate. Approximated + // with code-point offsets via `mb_substr`, exact only without combining/multi-code-point clusters. + pub fn slice(&self, start: i64, length: Option<i64>) -> Self { + Self::new(&shirabe_php_shim::mb_substr( + &self.string, + start, + length, + Some("UTF-8"), + )) } } |
