Using Gvim to write PHP to create Chinese garbled problem solving method in Windows _php skills

Source: Internet
Author: User
Tags diff processing text
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:

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
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 &sh =~ ' \<cmd '
Let cmd = ' "'. $VIMRUNTIME. ' \diff '
Let eq = ' "'
Let cmd = substitute ($VIMRUNTIME, ', ', ' ", ')." \diff "'
Let cmd = $VIMRUNTIME. ' \diff '
Silent execute '! '. Cmd. ' ' . Opt. Arg1. ' ' . Arg2. ' > '. Arg3. eq
"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 Encoding=utf-8
"The cause of the problem
Set Fileencoding=chinese
Set Fileencodings=ucs-bom,utf-8,chinese
Set Langmenu=zh_cn.utf-8
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
"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.

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: 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.