First: Find out the reason for the garbled. Always thought is the reason of the browser, the result I in CHROME,FIREFOX,IE9 inside all appear garbled, so the browser factor can exclude. To verify that I guess it was Gvim's reason,
I wrote a php file with Notepad (note)
Copy Code code as follows:
<?php
echo "Hello";
echo "The World";
?>
Results did not appear garbled, so the problem is on the Gvim, this conclusion is ripe.
So, began to study the Gvim configuration file (_VIMRC), now give you a look at the configuration before I generated garbled (note: I have modified before):
Copy Code code as follows:
Set nocompatible
SOURCE $VIMRUNTIME/vimrc_example.vim
SOURCE $VIMRUNTIME/mswin.vim
Behave Mswin
Set Diffexpr=mydiff ()
function Mydiff ()
Let opt = '-a--binary '
If &diffopt =~ ' icase ' | Let opt = opt. ' I. ' | endif
If &diffopt =~ ' Iwhite ' | Let opt = opt. '-B ' | endif
Let arg1 = v:fname_in
If Arg1 =~ ' | Let arg1 = ' "'. Arg1. '"' | endif
Let arg2 = V:fname_new
If Arg2 =~ ' | Let arg2 = ' "'. Arg2. '"' | endif
Let Arg3 = V:fname_out
If Arg3 =~ ' | Let Arg3 = ' "'. Arg3. '"' | endif
Let eq = '
If $VIMRUNTIME =~ '
If &sh =~ ' \<cmd '
Let cmd = ' "'. $VIMRUNTIME. ' \diff '
Let eq = ' "'
Else
Let cmd = substitute ($VIMRUNTIME, ', ', ' ", ')." \diff "'
endif
Else
Let cmd = $VIMRUNTIME. ' \diff '
endif
Silent execute '! '. Cmd. ' ' . Opt. Arg1. ' ' . Arg2. ' > '. Arg3. eq
Endfunction
"Set Default background color
Colors Desert
"Settings do not automatically back up
Set Nobackup
"Set default font and size
Set Guifont=courier_new:h12:cansi
Set TERMENCODING=GBK
Set Encoding=utf-8
"The cause of the problem
Set Fileencoding=chinese
Set Fileencodings=ucs-bom,utf-8,chinese
Set Langmenu=zh_cn.utf-8
SOURCE $VIMRUNTIME/delmenu.vim
SOURCE $VIMRUNTIME/menu.vim
Language Messages Zh_cn.utf-8
Language Messages Zh_cn.utf-8
Syntax enable
Syntax on
Here's what you need to say: the meaning of enconding,fileeconding,fileecondings in the config file:
Encoding:gvim internal use of the character encoding method, including Vim (buffer), menu text, message text and so on.
The user's manual suggests changing its value only in. VIMRC, and in fact it seems only meaningful to change its value in. vimrc.
The character encoding of the file currently edited in Fileencoding:gvim, and Vim saves the file as this character encoding (whether or not it is the case for new files).
When Fileencodings:gvim starts, it detects the character encoding of the file that is about to be opened, using the character encoding it lists, and sets the fileencoding to the final detected character encoding.
So it's best to put the Unicode encoding at the top of this list, and put the Latin coding latin1 on the last side.
Where: Chinese is cp963 code
Only here I suddenly remembered, my browsing the default character set is GBK, and _VIMRC in the set code is UTF-8, the two do not correspond,
Copy Code code as follows:
Colors Desert
Set Nobackup
Set Guifont=courier_new:h12:cansi
"Processing text displays garbled
Set Encoding=utf-8
Set Fileencodings=chinese
Set Fileencoding=chinese
"Processing menu and right key menu garbled
SOURCE $VIMRUNTIME/delmenu.vim
SOURCE $VIMRUNTIME/menu.vim
"Processing Consle output garbled
Language Messages Zh_cn.utf-8
Syntax enable
Syntax on
After the modification is completed, restart the Gvim, the Chinese garbled problem is solved.