cp: cannot create regular file 'foo': Invalid argument (with CJK script / encoding)

This is a wiki page. Be bold and improve it!

If you have any questions about the content on this page, don't hesitate to open a new ticket and we'll do our best to assist you.

Problem

After mounting a usb storage medium, I try to copy a file to it, but I get the following error:

$ cp 黃.txt /media/usb/
cp: cannot create regular file '/media/usb/黃.txt': Invalid argument

The problem occurs only with files which include Chinese (CJK) encoded characters.
The following works without problem:
$ cp test.txt /media/usb/

Solution

Check the options the usb medium has been mounted:

$ grep /media/usb/ /proc/mounts
/dev/sdf1 /media/usb vfat rw,nosuid,nodev,noexec,relatime,uid=1001,gid=1001,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro 0 0

Note the iocharset=ascii which is not optimal.

Unmount the usb, and remount it with the proper encoding option: iocharset=utf8.

Note that this option can also be set in /etc/fstab, if you had an entry there:

UUID=1234-ABCD /media/usb   vfat user,noauto,iocharset=utf8 0 0