Skip to content

amiga: show names in Latin-1 instead of UTF-8 - #56

Merged
reinauer merged 6 commits into
mainfrom
amiga/latin1-names
Nov 25, 2026
Merged

reinauer merged 6 commits into
mainfrom
amiga/latin1-names

Conversation

@reinauer

@reinauer reinauer commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

amiga: show names in Latin-1 instead of UTF-8

The backends decode Joliet, UDF, HFS and HFS+ names to UTF-8, and current mastering tools write Rock Ridge names in UTF-8 too. The handler passed those bytes to AmigaDOS unchanged, so Grüße.txt showed as GrüÃe.txt, could not be typed, and List ALL failed to enter a directory named like that.

This series converts names to ISO 8859-1 on Amiga builds. It includes the commit from #50, which this replaces.

What changes

  • Node names: converted in odfs_namefix_apply(), the one place every backend's readdir and lookup pass a name through, and before duplicates are looked for.
    • The metadata cache holds converted names, and a typed name is compared directly.
    • Two names that come out the same get the usual ~2 suffix.
  • Symbolic link targets and volume names: converted as well.
  • Characters outside Latin-1: shown as _, one per character. U+0080 to U+009F also become _, because the Amiga console acts on those codes.
    • Not ?: it is an AmigaDOS pattern character, and List ALL on AROS never returns from a directory that has one in its name (it locks an empty name, gets the parent again and lists that, without end). The last commit changes it, also for the lone UTF-16 surrogates and control characters that main already replaced with ?.
  • Names that are raw 8-bit already: a byte that is not part of a well-formed UTF-8 sequence is kept. Rock Ridge names written by Amiga mastering tools stay as they are.
  • Decomposed names: HFS+ stores Ä as A plus a combining diaeresis. A combining grave, acute, circumflex, tilde, diaeresis, ring or cedilla is merged with the letter before it where Latin-1 has that letter. This is off in the ROM profile (ODFS_FEATURE_CHARSET_COMPOSE).
  • UDF: 8-bit CS0 names are decoded to UTF-8 like the 16-bit ones (from udf: decode 8-bit CS0 names as Latin-1 to UTF-8 #50), so every backend hands over UTF-8 and one place converts.
  • Host tools: unchanged; they keep UTF-8. The conversion is a mount option, odfs_mount_opts_t.name_charset, which the Amiga handler sets.

Testing

  • Host: make check, golden-check, malformed-check and fuzz-check pass. New unit tests cover the converter, the duplicate handling, a Joliet tree, Rock Ridge readlink and the volume name.
  • Builds: every commit passes make check, builds for 68000, 68020, ROM and OS4 without warnings, and passes tests/aros/check_abi.sh.
  • Emulator (A4000/68040, OS 3.2, 68020 build), five images holding Grüße.txt, Ärger/Überraschung.txt, Preis 5€.txt, 日本.txt, 中国.txt and a link Länk:
Image List shows Type by Latin-1 name Volume name
Rock Ridge + Joliet (mkisofs, UTF-8) Grüße.txt, Ärger, Preis 5_.txt, __.txt, __.txt~2, Länk > Grüße.txt works, also through the link Größe
Joliet only same names, no link works (ASCII)
Rock Ridge with raw Latin-1 names Müller.txt, café/Straße.txt works (ASCII)
UDF (hdiutil) same names, link resolves works Größe
HFS+ (hdiutil, decomposed names) Ärger, Grüße.txt works Größe

On main the first image lists GrüÃe.txt and Ãrger, and List ALL reports "object not found" for the directory.

  • Regression: on the ASCII benchmark disc, List, Info and Dir ALL are identical to main, and the copied files match the ISO.
  • AmigaOS 4.1 FE Update 3 (QEMU pegasos2, handler as Kickstart module): a Joliet disc with Grüße.txt, Señor.txt, Preis 5€.txt, Żółć.txt and Čeština/Šárka.txt lists as Grüße.txt, Señor.txt, Preis 5_.txt, _ó__.txt and _e_tina/_árka.txt, where main shows the UTF-8 bytes. The Latin-1 names open.
  • AROS i386 (QEMU, nightly of 2 November): the same disc gives the same names, List ALL returns, and the Latin-1 names open. With ? as the replacement, List ALL on that disc did not return.
  • Not covered: AROS x86-64 and m68k at run time.

Speed

CDBench, 68020 build, same rig. A pure ASCII name costs the same as before: the hash loop in odfs_namefix_apply() stops at the first byte with bit 7 set, and only such names are converted.

seq KiB/s Discovery cold ExAll deep lock open from lock small open/read
main 209,022 9,901 12,950 141 160 304
this series 209,019 9,903 12,952 141 160 303

Size

Build main this series delta
68000 handler 84,056 84,476 +420
68020 handler 81,688 82,024 +336
ROM 31,208 31,536 +328
OS4 text 131,076 131,464 +388

Merging the accents accounts for 188 of the 68000 bytes and none of the ROM bytes.

Not in this series

  • Case: matching still folds only A to Z. grüße.TXT finds Grüße.txt; ÄRGER does not find Ärger.
  • Other character sets: names always go to Latin-1. Using the system's character set through codesets.library is amiga: names in the system's character set, from codesets.library #58.
  • Long names: a name is cut to the node limit as UTF-8 before it is converted, so a very long name of non-Latin characters comes out shorter than it could.

The backends decode every name to UTF-8, but AmigaOS shows and
compares names in an 8-bit character set, so a Joliet, UDF or HFS name
with an umlaut comes out as two wrong characters there.

Add odfs_utf8_to_latin1(), which rewrites a string in place: Latin-1
never needs more bytes than UTF-8. A character outside Latin-1 becomes
'?', and so do U+0080 to U+009F, which are control codes that the
Amiga console would act on.

A byte that is not part of a well-formed sequence is copied as it is.
Rock Ridge names written by Amiga mastering tools are raw Latin-1,
and they must keep working once the handler converts names. Overlong
forms count as malformed, so that none can produce a NUL or a '/'.

Nothing calls the function yet. It is built when
ODFS_FEATURE_CHARSET_BUILTIN is set, which so far had no effect.
Add odfs_mount_opts_t.name_charset. With ODFS_NAMES_LATIN1, node
names, symbolic link targets and the volume name are converted from
UTF-8 with odfs_utf8_to_latin1(); the default, ODFS_NAMES_UTF8, leaves
them as the backends decode them.

Node names are converted in odfs_namefix_apply(), the one place every
backend's readdir and lookup pass a name through, and before it looks
for duplicates. So two names that differ in UTF-8 but come out the
same, like two names without a single Latin-1 character, are told
apart with the usual "~2" suffix, the metadata cache holds converted
names, and a lookup compares the name it is given directly.

The function runs for every directory entry read and already walks
the name to hash it. That loop now stops at a byte with bit 7 set, so
a pure ASCII name costs no more than before; only other names are
converted and then hashed again.

The backends cannot see the mount options, so the choice is kept in
the block cache, which every backend call is handed.

Rock Ridge's readlink scans the directory records itself for the
link's name and converts each candidate before comparing. The target
is converted in odfs_readlink() for all backends.
The backends decode Joliet, UDF, HFS and HFS+ names to UTF-8, and
current mastering tools write Rock Ridge names in UTF-8 as well. The
handler passed these bytes to AmigaDOS unchanged, so every character
outside ASCII showed as two or three wrong ones, and such a name could
not be typed.

Mount with ODFS_NAMES_LATIN1. A character Latin-1 does not have is
shown as '?'. Rock Ridge names that are raw Latin-1, as Amiga
mastering tools write them, are not valid UTF-8 and stay as they are.

Together with the two commits before it, this adds 332 bytes to the
68000 handler, 272 to the 68020 one and 324 to the ROM build.
OSTA CS0 with compression ID 8 stores one byte per character, and
those bytes are the Unicode code points U+0000..U+00FF, i.e. Latin-1.
udf_decode_cs0() and udf_decode_dstring() copied them verbatim into
node names and the volume name, so a non-ASCII name produced invalid
UTF-8 even though odfs_node_t names are UTF-8 and the 16-bit CS0 path
already converts to UTF-8.

Encode bytes >= 0x80 as two-byte UTF-8 sequences, and let
udf_decode_dstring() reuse udf_decode_cs0() instead of carrying its
own copy of the decoder.

Host tools that expect UTF-8 now get valid names. On AmigaOS the
handler converts names to Latin-1, so these names look the same as
before, except for the control codes 0x80 to 0x9F, which become '?'.
HFS+ stores every name decomposed: "Ärger" is "A", U+0308 (combining
diaeresis), "rger". Discs mastered on a Mac from such names carry the
same form in their Joliet and Rock Ridge trees. Converted character
by character, the accent has no Latin-1 equivalent, so the name came
out as "A?rger".

When a combining grave, acute, circumflex, tilde, diaeresis, ring or
cedilla follows a letter and Latin-1 has the accented letter, replace
the letter with it. Any other combination still gives the letter and
a '?'.

The new ODFS_FEATURE_CHARSET_COMPOSE controls this. It is off in the
ROM profile, which has no HFS+ support, and costs 188 bytes on the
68000 elsewhere.
A character Latin-1 does not have came out as '?'. So did a lone
UTF-16 surrogate, and a control character in a Mac name or in CD-Text.

'?' is an AmigaDOS pattern character. On AROS, List ALL does not come
back from a directory whose name has one. Having listed the parent, it
asks for a lock on an empty name where it means the directory, gets the
parent again, lists that, and so on without end. Seen on AROS i386 with
a Joliet directory named in Czech, which came out as "?e?tina". AmigaOS
3.2 and 4.1 list the same disc without trouble.

Use '_' in all those places. It means nothing in a pattern.
@reinauer
reinauer merged commit 92d02cd into main Nov 25, 2026
3 checks passed
@reinauer
reinauer deleted the amiga/latin1-names branch November 27, 2026 04:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant