Vim code conversion and file mode type conversion __ encoding

Source: Internet
Author: User
I. Coding problems
Encoding is common for GBK utf-8 Big5 cp936
1, view the current text encoding
: Set Fenc
: Set fileencoding
2, modify the terminal code, you can set up a terminal or in vim
: Set tenc= encoding
: Set Termencoding=utf-8
3. Displays the text in the specified encoding, but does not save it to the file.
: Set enc= encoding
: Set Encoding=utf-8
4, the conversion of the current text encoding for the specified encoding
: Set fenc= encoding
: Set Fileencodings=utf-8, then W (save) can be converted to UTF8 format,
: Set fileencodings=cp936, then W (save) can be converted to ANSI format.


Mode type of text
The generic file type pattern is Dos,unix
1. View the mode type of the current text
: Set FF
2, set to DOS mode, that is, the format of Windows
: Set Ff=dos
3, set to UNIX mode
: Set Ff=unix
:%s/^m//g


Iii. Coding Conversion Tools
1, enconv conversion file encoding, such as to convert a GBK encoded file into UTF-8 encoding
Enconv-l zh_cn-x UTF-8 filename
2, iconv conversion, iconv command format is as follows
Iconv-f ENCODING-T Encoding Inputfile
Iconv-f UTF-8-T GBK file1-o file
Bulk conversion Scripts
#!/bin/bash
If ["$#"!= "2"]; then
  echo "Usage: ' basename $ ' dir filter '
  exit
fi
dir=$1
filter =$2
echo
$dir-name "$", do
  echo "$file"
  #iconv-F gbk-t utf8-o $file $file
  Iconv-f utf8-t gbk-c-o $file $file done
How to use
~/iconv_shell.sh./*java

3, CONVMV Conversion code
Convmv-f Source code-T new encoding [option] filename
Analog conversion comparison
Convmv-f gbk-t UTF-8 *.mp3
True Conversion command
Convmv-f gbk-t UTF-8--notest *.mp3
4, eNCA automatic recognition conversion
View Current file encoding
Enca-l ZH_CN Ip.txt
Conversion encoding
Enca-l current language-x target encoded file name
Bulk conversions
Enca-l zh_cn-x Utf-8 *
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.