1. vfat/Linux
Default is ascii, Chinese/utf-8 is not shown OK
[root@localhost ~]# mount |grep sdc
/dev/sdc1 on /mnt/temp type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)
Now it is OK!!!
[root@localhost iot]# mount -t vfat -o iocharset=utf8 /dev/sdc1 /mnt/temp/
[root@localhost iot]# cat /proc/version
Linux version 4.13.0+ (lake@localhost.localdomain) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-4) (GCC)) #7 SMP Thu Oct 25 23:11:38 EDT 2018
[root@localhost iot]# mount |grep sdc1
/dev/sdc1 on /mnt/temp type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=utf8,shortname=mixed,errors=remount-ro)
[root@localhost iot]#
2. Overrlap a LCXXX seting by export LC_ALL=C (POSIX standard)
lake@lake-Latitude-5491:~$ export |grep LC (This is for UTF-8)
declare -x LC_ADDRESS="zh_CN.UTF-8"
declare -x LC_IDENTIFICATION="zh_CN.UTF-8"
declare -x LC_MEASUREMENT="zh_CN.UTF-8"
declare -x LC_MONETARY="zh_CN.UTF-8"
declare -x LC_NAME="zh_CN.UTF-8"
declare -x LC_NUMERIC="zh_CN.UTF-8"
declare -x LC_PAPER="zh_CN.UTF-8"
declare -x LC_TELEPHONE="zh_CN.UTF-8"
declare -x LC_TIME="zh_CN.UTF-8"
lake@lake-Latitude-5491:~$ export LC_ALL=C
lake@lake-Latitude-5491:~$ export |grep LC
declare -x LC_ADDRESS="zh_CN.UTF-8"
declare -x LC_ALL="C"
declare -x LC_IDENTIFICATION="zh_CN.UTF-8"
declare -x LC_MEASUREMENT="zh_CN.UTF-8"
declare -x LC_MONETARY="zh_CN.UTF-8"
declare -x LC_NAME="zh_CN.UTF-8"
declare -x LC_NUMERIC="zh_CN.UTF-8"
declare -x LC_PAPER="zh_CN.UTF-8"
declare -x LC_TELEPHONE="zh_CN.UTF-8"
declare -x LC_TIME="zh_CN.UTF-8"
lake@lake-Latitude-5491:~$
3. Windows
- Start -> Run -> regedit
- Go to
[HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun]
- Change the value to
chcp 65001
Bat
@ECHO OFF
REM change CHCP to UTF-8
CHCP 65001
CLS
Cmd
echo "Windows 10 cmd batch files saved as UTF-8 txt file"
chcp 65001
C:\work\ffmpeg-4.3-win64-shared\bin\ffmpeg -i "01.爱的力量(席琳.迪翁).ape" "01.爱的力量(席琳.迪翁).mp3"
C:\work\ffmpeg-4.3-win64-shared\bin\ffmpeg -i "02.雨中的旋律(贾森.多诺南).ape" "02.雨中的旋律(贾森.多诺南).mp3"
C:\>chcp
Active code page: 936 =====> GBK
C:\>chcp 65001
Active code page: 65001
4. Git
[lake@lake-aliyun-sh-china ~]$ cat .gitconfig
[gui]
encoding = utf-8
5. Python
#-*- coding:UTF-8 -*-
#!/usr/bin/python
# coding=utf-8
# ============================================================================
# ============================================================================
import os
import sys
def set_log_file(ofile):
global logf
logf = open(ofile,'wt',encoding='utf-8')
5.1 execute python MinGW
@ MINGW32 ~/ $
$ export PYTHONIOENCODING=UTF-8 ; export PYTHONUNBUFFERED=1
@ MINGW32 ~/(master)
$ /c/Python36/python.exe main.py
5.2 Execute python Windows command
C:\>set "PYTHONIOENCODING=UTF-8" && set "PYTHONUNBUFFERED=1"
C:\> C:\Python36\python.exe ./main.py -i input