-
Notifications
You must be signed in to change notification settings - Fork 98
Description
When opening a UTF-16 encoded text file (UTF-16LE or UTF-16BE, including files with a BOM and CRLF line endings), COSMIC Editor fails to open the file or treats it as invalid UTF-8.
The file contents are not shown.
After manually converting the file to UTF-8 using iconv, the same file opens correctly.
COSMIC Editor should be able to handle UTF-16 encoded text files by either:
automatically detecting UTF-16 (LE/BE) and converting internally to UTF-8, or
prompting the user to select an encoding, or
offering a “Reopen with Encoding” option.
At minimum, the file contents should be visible without requiring manual conversion.
$ printf "Line 1\r\nLine 2\r\n" > cosmic-utf16-repro-src.txt
$ iconv -f UTF-8 -t UTF-16 cosmic-utf16-repro-src.txt > cosmic-utf16-repro.txt
$ file cosmic-utf16-repro.txt
cosmic-utf16-repro.txt: Unicode text, UTF-16, little-endian text, with CRLF line terminators
$ cosmic-edit cosmic-utf16-repro.txt
gebruiker@2001-1c00-2710-bb00-c097-77fe-8331-610f:~/Downloads$ [2026-01-26T18:55:24Z ERROR cosmic_edit::tab] failed to open "/home/gebruiker/Downloads/cosmic-utf16-repro.txt": stream did not contain valid UTF-8
[2026-01-26T18:55:24Z WARN wgpu_hal::gles::egl] Re-initializing Gles context due to Wayland window
[2026-01-26T18:55:24Z WARN sctk_adwaita::buttons] Ignoring unknown button type:
gebruiker@2001-1c00-2710-bb00-c097-77fe-8331-610f:~/Downloads$
$ cat /etc/os-release
NAME="Fedora Linux"
VERSION="43 (COSMIC)"
RELEASE_TYPE=stable
ID=fedora
VERSION_ID=43
VERSION_CODENAME=""
PRETTY_NAME="Fedora Linux 43 (COSMIC)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:43"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f43/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://pagure.io/fedora-cosmic/SIG/issues"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=43
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=43
SUPPORT_END=2026-12-02
VARIANT="COSMIC"
VARIANT_ID=cosmic
cosmic editor version 0.1.0