fix(format): flag non-ASCII link names as UTF-8
The writer marked every link name ASCII, so a name such as "größe" was stored as UTF-8 bytes under the ASCII character set (h5py reports cset 0 for it). Names that are not plain ASCII now carry the UTF-8 flag, as h5py writes them; ASCII names are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -220,6 +220,16 @@ fn add_refcount(w: &mut ObjectHeaderWriter, refcount: u32) {
|
||||
}
|
||||
}
|
||||
|
||||
/// The character set a link name is written with: UTF-8 when it is not
|
||||
/// plain ASCII, as h5py writes it.
|
||||
fn name_charset(name: &str) -> CharacterSet {
|
||||
if name.is_ascii() {
|
||||
CharacterSet::Ascii
|
||||
} else {
|
||||
CharacterSet::Utf8
|
||||
}
|
||||
}
|
||||
|
||||
/// The Link message for `link`, whose group and dataset targets are at the
|
||||
/// given addresses (indexed as in the writer tree).
|
||||
fn link_message(link: &writer_tree::Link, group_addrs: &[u64], ds_addrs: &[u64]) -> LinkMessage {
|
||||
@@ -242,7 +252,7 @@ fn link_message(link: &writer_tree::Link, group_addrs: &[u64], ds_addrs: &[u64])
|
||||
name: link.name.clone(),
|
||||
link_target,
|
||||
creation_order: link.creation_order,
|
||||
charset: CharacterSet::Ascii,
|
||||
charset: name_charset(&link.name),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user