Repository navigation
amiga: show names in Latin-1 instead of UTF-8 - #56
Merged
Merged
Conversation
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.
This was referenced Nov 24, 2026
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.txtshowed asGrüÃe.txt, could not be typed, andList ALLfailed 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
odfs_namefix_apply(), the one place every backend's readdir and lookup pass a name through, and before duplicates are looked for.~2suffix._, one per character. U+0080 to U+009F also become_, because the Amiga console acts on those codes.?: it is an AmigaDOS pattern character, andList ALLon 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?.ÄasAplus 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).odfs_mount_opts_t.name_charset, which the Amiga handler sets.Testing
make check,golden-check,malformed-checkandfuzz-checkpass. New unit tests cover the converter, the duplicate handling, a Joliet tree, Rock Ridge readlink and the volume name.make check, builds for 68000, 68020, ROM and OS4 without warnings, and passestests/aros/check_abi.sh.Grüße.txt,Ärger/Überraschung.txt,Preis 5€.txt,日本.txt,中国.txtand a linkLänk:ListshowsTypeby Latin-1 nameGrüße.txt,Ärger,Preis 5_.txt,__.txt,__.txt~2,Länk > Grüße.txtGrößeMüller.txt,café/Straße.txtGrößeÄrger,Grüße.txtGrößeOn main the first image lists
GrüÃe.txtandÃrger, andList ALLreports "object not found" for the directory.List,InfoandDir ALLare identical to main, and the copied files match the ISO.Grüße.txt,Señor.txt,Preis 5€.txt,Żółć.txtandČeština/Šárka.txtlists asGrüße.txt,Señor.txt,Preis 5_.txt,_ó__.txtand_e_tina/_árka.txt, where main shows the UTF-8 bytes. The Latin-1 names open.List ALLreturns, and the Latin-1 names open. With?as the replacement,List ALLon that disc did not return.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.Size
Merging the accents accounts for 188 of the 68000 bytes and none of the ROM bytes.
Not in this series
grüße.TXTfindsGrüße.txt;ÄRGERdoes not findÄrger.