安装NetBeans 8.0后打开项目中utf-8编码格式的php文件的时候,竟然提示使用gbk打开会有乱码,竟然不能选择用什么模式打开,今天上官方看了下,原来官方就有解决方法~哈哈~这招可以解决目前所有的版本,全部文件将用UTF-8编码打开。
For those who need to use international and multibyte characters, NetBeans can support UTF-8 editing. To enable it, go to your NetBeans installation directory and find the etc folder. There will be a file there called netbeans.conf .
This file keeps some configuration for NetBeans, including the default command line arguments. These are parameters that will be sent to a new starting Netbeans IDE.
Every argument lives inside a double-quoted variable called netbeans_default_options , and each one is separated from another by a space.
To enable UTF-8 in NetBeans, just place this parameter anywhere on the list of netbeans_default_options:-J-Dfile.encoding=UTF-8
中文解释一下:
1.找到你的Netbeans安装目录下的etc文件夹,如C:\Program Files\NetBeans 8.0\etc
2.用记事本打开netbeans.conf
3.找到netbeans_default_options这一句(没带#号的,带#号的是注释)
4.在最后面加上一个空格,再加入-J-Dfile.encoding=UTF-8
如我现在的设置:
netbeans_default_options=”-J-client -J-Xss2m -J-Xms32m -J-XX:PermSize=32m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true -J-Dfile.encoding=UTF-8”
这样,打开的文件所有都默认使用UTF-8编码打开了~哈哈,不再有乱码。
如果需要打开GBK编码格式的文件,那就把刚刚那段添加的去掉就可以了。