I'm trying to find out how borg interacts with the locale, namely LC_CTYPE.
I'm deeply convinced it mostly shouldn't. Unix path names are octet strings containing any octet but 00; only 2F has some special meaning.
While most humans tend to interpret path names as character srings, most programs shouldn't (exceptions are humans asking to sort names according to a given locale etc.).
I can't make any sense out of what borg (or Python, I don't speak python) does in this area. I'm running 1.2.2 with python 3.10 on NetBSD-10, in case that matters.
I created a file with octet sequence 53 6d c3 b6 72 65 62 72 c3 96 64 (interpreted as UTF-8, that's „SmörebrÖd“), created an archive containing that file with borg create --list (with and without --log-json) and ran borg list (with and without --json-lines) and borg extract on the directory containing that file.
I did this with three locales, namely C, de_DE.UTF-8 and de_DE.ISO8859-1.
I tried all combinations of locale used on create and on list/extract.
Both when used on create and on list/ectract, C and de_DE.UTF-8 behvaved exactly the same.
I also found ZERO differences between path and bpath as a --format item in borg list (for --json-lines, that's expected, but without, it's not).
When I create under a C or UTF-8 locale, create --list (run through hexdump -C to be sure) outputs 53 6d c3 b6 72 65 62 72 c3 96 64, which is what I would expect. With --log-json, it outputs Sm\u00f6rebr\u00d6d, which looks like someone tried to convert the filename to Latin-1.
When I list that archive with a C or UTF-8 locale, I get 53 6d c3 b6 72 65 62 72 c3 96 64 (expected) without --log-json, but Sm\u00f6rebr\u00d6d (unexpected) with --log-json. When I extract with a C or UTF-8 locale, the resulting file has 53 6d c3 b6 72 65 62 72 c3 96 64 as a file name as expected.
When I list that archive with a L1 locale, I get 53 6d f6 72 65 62 72 d6 64 without --json-lines, which is the filename converted to L1; with --json-lines, I again get Sm\u00f6rebr\u00d6d (unexpectedly converted to L1).
When I create under a L1 locale, it gets even weirder. create --list gives 53 6d c3 b6 72 65 62 72 c3 96 64 (the original octet sequence), create --list --log-json gives Sm\u00c3\u00b6rebr\u00c3\u0096d which (now suprisingly) is what I'd expect under any locale combination whatsoever.
When I list that archive under a C or UTF-8 locale, I get 53 6d c3 83 c2 b6 72 65 62 72 c3 83 c2 96 64 without --json-lines (which looks like UTF-8 interpreted as L1 converted to UTF-8) and Sm\u00c3\u00b6rebr\u00c3\u0096d (expected) with --json-lines
When I list under L1, I get 53 6d c3 b6 72 65 62 72 c3 96 64 (expected) resp. Sm\u00c3\u00b6rebr\u00c3\u0096d (also expected).
When I extract under a C or UTF-8 locale, that results in a file with octet sequence 53 6d c3 83 c2 b6 72 65 62 72 c3 83 c2 96 64 as a name (looks like doubly L1-to-UTF-8 converted); when I extract under a L1 locale, the name is 53 6d c3 b6 72 65 62 72 c3 96 64 as expected.
I hope I transcribed that correctly.
There may be hysterical reasons for the current behaviour.
What I need is (apart from extract re-creating the original file names) is that create --list --log-json (I need JSON to deal with file names containng newlines) lists the original file names. It would also be nice to have list --json-lines listing the original names, but I can get away with --format {path}{NUL} instead.
It currently looks like running everything with L1 would do what I need, but that looks wrong plus I ran all former create operations with a C locale.
Plus, locale shouldn't matter at all, I'm convinced.