mirror of https://github.com/encounter/nod-rs.git
Ignore Shift JIS decoding errors in Fst::get_name
This commit is contained in:
parent
be4672471d
commit
d4bca2caa8
|
@ -119,10 +119,9 @@ impl<'a> Fst<'a> {
|
||||||
let c_string = CStr::from_bytes_until_nul(name_buf).map_err(|_| {
|
let c_string = CStr::from_bytes_until_nul(name_buf).map_err(|_| {
|
||||||
format!("FST: name at offset {} not null-terminated", node.name_offset())
|
format!("FST: name at offset {} not null-terminated", node.name_offset())
|
||||||
})?;
|
})?;
|
||||||
let (decoded, _, errors) = SHIFT_JIS.decode(c_string.to_bytes());
|
let (decoded, _, _) = SHIFT_JIS.decode(c_string.to_bytes());
|
||||||
if errors {
|
// Ignore decoding errors, we can't do anything about them. Consumers may check for
|
||||||
return Err(format!("FST: Failed to decode name at offset {}", node.name_offset()));
|
// U+FFFD (REPLACEMENT CHARACTER), or fetch the raw bytes from the string table.
|
||||||
}
|
|
||||||
Ok(decoded)
|
Ok(decoded)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue