Skip to main content

java_trim

Function java_trim 

Source
pub fn java_trim(s: &str) -> &str
Expand description

Faithful port of Java String.trim(): strips only leading/trailing chars whose codepoint is <= U+0020 (NOT the full Unicode White_Space set that Rust’s str::trim uses). Use this everywhere the Java source calls .trim().

Java’s String.trim() only removes characters with codepoint values 0–32 (space through control chars), while Rust’s str::trim() removes the entire Unicode White_Space category. This means non-breaking space (U+00A0) and other Unicode spaces are trimmed by Rust but NOT by Java, causing empty/length guard logic to diverge.