aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src/string.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-02 06:30:17 +0900
committernsfisis <nsfisis@gmail.com>2026-08-02 06:30:17 +0900
commitee5025bb27862a7d2231911c08e1e0e1fa7dab20 (patch)
tree24a427d8f888bcb63a60b981cf7b9c0ee0dd35ad /crates/shirabe-php-shim/src/string.rs
parent4a220b09967f84f830db029501dbef6efc4ee9f9 (diff)
downloadphp-shirabe-ee5025bb27862a7d2231911c08e1e0e1fa7dab20.tar.gz
php-shirabe-ee5025bb27862a7d2231911c08e1e0e1fa7dab20.tar.zst
php-shirabe-ee5025bb27862a7d2231911c08e1e0e1fa7dab20.zip
refactor(console-io): make ensure_valid_utf8 a no-op, drop iconv shim
Rust's &str is always valid UTF-8, so the mbstring/iconv sanitization chain can never trigger. Reduce it to a no-op with a TODO(phase-c) marker: once the codebase strictly separates Vec<u8> from String, this should take &[u8] and convert lossily. This removes the last caller of the php-shim iconv(), so delete it as well. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src/string.rs')
-rw-r--r--crates/shirabe-php-shim/src/string.rs18
1 files changed, 0 insertions, 18 deletions
diff --git a/crates/shirabe-php-shim/src/string.rs b/crates/shirabe-php-shim/src/string.rs
index 28acb3bb..e0c84836 100644
--- a/crates/shirabe-php-shim/src/string.rs
+++ b/crates/shirabe-php-shim/src/string.rs
@@ -421,24 +421,6 @@ pub fn mb_convert_variables(_to: &str, _from: &str, _vars: &mut Vec<String>) ->
Some(_from.to_string())
}
-pub fn iconv(_in_charset: &str, _out_charset: &str, _string: &str) -> Option<String> {
- let from = canonical_encoding(_in_charset);
- // The output charset may carry a "//TRANSLIT" / "//IGNORE" suffix.
- let to_base = _out_charset.split("//").next().unwrap_or(_out_charset);
- let to = canonical_encoding(to_base);
- // ASCII is a subset of UTF-8, so any conversion among ASCII/UTF-8 that targets UTF-8 is a
- // byte-level no-op.
- if to == "UTF-8" && matches!(from.as_str(), "UTF-8" | "ASCII") {
- return Some(_string.to_string());
- }
- if to == "ASCII" && from == "ASCII" {
- return Some(_string.to_string());
- }
- // TODO(phase-d): general iconv conversion needs encoding tables and //TRANSLIT///IGNORE handling
- // for non-UTF-8 targets, which have not been ported yet.
- todo!("iconv {} -> {}", from, to)
-}
-
/// Resolve PHP array_slice/substr-style (offset, length) into a `[start, end)`
/// pair of indices, honouring negative offsets and lengths.
fn php_slice_bounds(len: i64, offset: i64, length: Option<i64>) -> (usize, usize) {