I have a file containing contents(Unicode escape string in specific) like this:
title=\"\u5e2e\u4e0a\u5934\u6761\">\u5e2e\u4e0a\u5934\u6761<\/a><\/li>\n
in my working Vim window and want to show it as Chinese.
This is the output of the locale command in my terminal:
LANG=en_US.UTF•8
LANGUAGE=en
LC_CTYPE=en_US.UTF•8
LC_NUMERIC=en_US.UTF•8
LC_TIME=en_US.UTF•8
LC_COLLATE=“en_US.UTF-8”
LC_MONETARY=en_US.UTF•8
LC_MESSAGES=“en_US.UTF-8”
LC_PAPER=en_US.UTF•8
LC_NAME=en_US.UTF•8
LC_ADDRESS=en_US.UTF•8
LC_TELEPHONE=en_US.UTF•8
LC_MEASUREMENT=en_US.UTF•8
LC_IDENTIFICATION=en_US.UTF•8
LC_ALL=
And the OS I use is Ubuntu 14.04.
I know I can print the Chinese characters using Python:
print u"\u5e2e\u4e0a\u5934\u6761".encode('utf-8')
# encode the unicode string to utf-8 string which matches the terminal encoding.
# If I write the result to a file I can see Chinese characters if I open it by vim.
Is there a way for me to make vim to show the Chinese characters? Can I do this using vimscript inside vim with a toggle to switch between these two encoding systems if possible?
Aware that I can realize the function with the thoughts above I want to know if there is existing scripts, which will prevent me recreating wheals.
:set fileencoding=utf8or:set encoding=utf8will do :) – SibiCoder Jul 05 '16 at 12:25