From d4bca2caa8a5b4d36f2293487760955373b41bbf Mon Sep 17 00:00:00 2001 From: Luke Street Date: Fri, 18 Oct 2024 00:02:37 -0600 Subject: [PATCH] Ignore Shift JIS decoding errors in Fst::get_name --- nod/src/disc/fst.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nod/src/disc/fst.rs b/nod/src/disc/fst.rs index abde83c..25a4515 100644 --- a/nod/src/disc/fst.rs +++ b/nod/src/disc/fst.rs @@ -119,10 +119,9 @@ impl<'a> Fst<'a> { let c_string = CStr::from_bytes_until_nul(name_buf).map_err(|_| { format!("FST: name at offset {} not null-terminated", node.name_offset()) })?; - let (decoded, _, errors) = SHIFT_JIS.decode(c_string.to_bytes()); - if errors { - return Err(format!("FST: Failed to decode name at offset {}", node.name_offset())); - } + let (decoded, _, _) = SHIFT_JIS.decode(c_string.to_bytes()); + // Ignore decoding errors, we can't do anything about them. Consumers may check for + // U+FFFD (REPLACEMENT CHARACTER), or fetch the raw bytes from the string table. Ok(decoded) }