kio_ftp: Detect legacy encodings when the server does not support UTF-8

When an FTP server does not support UTF-8, kio_ftp currently keeps using the default encoding, which can lead to incorrectly decoded directory listings and broken handling of non-ASCII file names.

This change first tries to enable UTF-8 explicitly with OPTS UTF8 ON. If the server accepts it, kio_ftp continues to use UTF-8 as before. If not, the worker feeds non-ASCII bytes from directory listing lines into KEncodingProber and uses the detected encoding once the result is considered reliable. If no reliable result is found by the end of the listing, it falls back to a locale-based legacy encoding from KCodecs.

This patch depends on the corresponding KCodecs.

Please review/merge the MR first: kcodecs!110

This improves compatibility with legacy FTP servers that do not implement UTF-8 negotiation, while preserving the existing behavior for UTF-8-capable servers.

No behavior change for servers that already support UTF-8.

CCBUG: 269370

CCBUG: 165044

Edited by Ramil Nurmanov

Merge request reports

Loading