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:
osobh
2026-09-26 08:34:04 -05:00
co-authored by Claude Opus 5.5
parent d102c06306
commit bd36fe883b
3 changed files with 32 additions and 1 deletions
@@ -592,3 +592,21 @@ fn track_order_lists_members_in_creation_order() {
assert_eq!(out, r#"["aaa", ["soft", "aaa"], 21]"#);
h5dump_ok(&path);
}
#[test]
fn non_ascii_names_are_utf8() {
skip_if_no_python!();
let dir = tempfile::tempdir().unwrap();
let mut b = FileBuilder::new();
b.create_dataset("größe/wert").with_i32_data(&[1]);
let path = write(&dir, "utf8.h5", b);
let out = h5py(
&path,
"with h5py.File(path, 'r') as f:\n\
\x20 l = f.id.links.get_info('größe'.encode())\n\
\x20 print(json.dumps([list(f), list(f['größe']), l.cset], ensure_ascii=False))",
);
assert_eq!(out, r#"[["größe"], ["wert"], 1]"#);
let f = File::open(&path).unwrap();
assert_eq!(f.dataset("größe/wert").unwrap().read_i32().unwrap(), [1]);
}