aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-php-shim/src/string.rs
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-08-09 07:47:48 +0900
committernsfisis <nsfisis@gmail.com>2026-08-09 07:48:16 +0900
commit20a876d44a7f7fe8f5d4cc77eb79a9a359aaf150 (patch)
tree2501c7f9b94e0bb2f47f1b2295583c543b52e76b /crates/shirabe-php-shim/src/string.rs
parent627aaead32dcf38bed255012fcf7965d9553f52e (diff)
downloadphp-shirabe-20a876d44a7f7fe8f5d4cc77eb79a9a359aaf150.tar.gz
php-shirabe-20a876d44a7f7fe8f5d4cc77eb79a9a359aaf150.tar.zst
php-shirabe-20a876d44a7f7fe8f5d4cc77eb79a9a359aaf150.zip
refactor(php-shim): remove shim functions with no callers
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe-php-shim/src/string.rs')
-rw-r--r--crates/shirabe-php-shim/src/string.rs47
1 files changed, 0 insertions, 47 deletions
diff --git a/crates/shirabe-php-shim/src/string.rs b/crates/shirabe-php-shim/src/string.rs
index 331a4ceb..575bc16d 100644
--- a/crates/shirabe-php-shim/src/string.rs
+++ b/crates/shirabe-php-shim/src/string.rs
@@ -834,53 +834,6 @@ fn php_to_float(v: &PhpMixed) -> f64 {
}
}
-pub fn html_entity_decode(_s: &str) -> String {
- // TODO(phase-c): only numeric entities and the most common named entities (the HTML 4.01 markup
- // set PHP enables by default) are decoded; the full named-entity table is not ported.
- let chars: Vec<char> = _s.chars().collect();
- let mut out = String::with_capacity(_s.len());
- let mut i = 0;
- while i < chars.len() {
- if chars[i] == '&' {
- if let Some(rel) = chars[i + 1..].iter().position(|&c| c == ';') {
- let entity: String = chars[i + 1..i + 1 + rel].iter().collect();
- if let Some(decoded) = decode_html_entity(&entity) {
- out.push_str(&decoded);
- i = i + 1 + rel + 1;
- continue;
- }
- }
- out.push('&');
- i += 1;
- } else {
- out.push(chars[i]);
- i += 1;
- }
- }
- out
-}
-
-fn decode_html_entity(entity: &str) -> Option<String> {
- if let Some(num) = entity.strip_prefix('#') {
- let code = if let Some(hex) = num.strip_prefix('x').or_else(|| num.strip_prefix('X')) {
- u32::from_str_radix(hex, 16).ok()?
- } else {
- num.parse::<u32>().ok()?
- };
- return char::from_u32(code).map(|c| c.to_string());
- }
- // PHP's default flags (ENT_QUOTES | ENT_HTML401) do not include the XML-only `apos`.
- let c = match entity {
- "amp" => '&',
- "lt" => '<',
- "gt" => '>',
- "quot" => '"',
- "nbsp" => '\u{00A0}',
- _ => return None,
- };
- Some(c.to_string())
-}
-
pub fn bin2hex(_data: &[u8]) -> String {
_data.iter().map(|b| format!("{:02x}", b)).collect()
}