Use UTF-16 encoding for strings rather than UCS-2
The MTP spec is somewhat ambiguous and says that:
Strings in PTP (and thus MTP) consist of standard 2-byte Unicode
characters as defined by ISO 10646.
This was interpreted to mean UCS-2 encoding, but I think that even
at the time the PTP spec was written, ISO 10646 had formally been
amended so that UTF-16 replaced UCS-2 as the 2-byte encoding.
We've gone a surprisingly long time without this being an issue, but
if you do try and construct a filename with supplementary plane
codepoints (most likely emoji characters in this day and age), libmtp
will fail to send or receive them.
Fortunately, as we use iconv, fixing this is a simple matter of
telling it to use UTF-16LE instead of UCS-2LE.
I did not attempt to rename any of the functions that include 'ucs2'
in their name. Let me know if you want me to do that.
Reported-by: Jerry Zhang <[email protected]>
1 file changed