UTF-8 setting Linux mount /Windows Active code page/Python

59 篇文章 0 订阅
54 篇文章 0 订阅

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 

  1. Start -> Run -> regedit
  2. Go to [HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor\Autorun]
  3. 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
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值