MCPcopy Index your code
hub / github.com/RustPython/RustPython / decomposition

Method decomposition

crates/stdlib/src/unicodedata.rs:237–253  ·  view source on GitHub ↗
(&self, character: PyStrRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

235
236 #[pymethod]
237 fn decomposition(&self, character: PyStrRef, vm: &VirtualMachine) -> PyResult<String> {
238 let ch = match self.extract_char(character, vm)?.and_then(|c| c.to_char()) {
239 Some(ch) => ch,
240 None => return Ok(String::new()),
241 };
242 let chars: Vec<char> = ch.decomposition_map().collect();
243 // If decomposition maps to just the character itself, there's no decomposition
244 if chars.len() == 1 && chars[0] == ch {
245 return Ok(String::new());
246 }
247 let hex_parts = chars.iter().map(|c| format!("{:04X}", *c as u32)).join(" ");
248 let tag = match ch.decomposition_type() {
249 Some(DecompositionType::Canonical) | None => return Ok(hex_parts),
250 Some(dt) => decomposition_type_tag(dt),
251 };
252 Ok(format!("<{tag}> {hex_parts}"))
253 }
254
255 #[pymethod]
256 fn digit(

Callers 3

test_decompositionMethod · 0.80

Calls 9

newFunction · 0.85
decomposition_type_tagFunction · 0.85
extract_charMethod · 0.80
collectMethod · 0.80
to_charMethod · 0.45
lenMethod · 0.45
joinMethod · 0.45
mapMethod · 0.45
iterMethod · 0.45

Tested by 3

test_decompositionMethod · 0.64