SCITE中文乱码

118 views
Skip to first unread message

scite

unread,
Apr 11, 2008, 9:14:12 AM4/11/08
to SciTE研究 - 中文小组
把编码设置成GBK的,看utf8的中文乱码。设置成utf8的编码,utf8中文正常了,GBK的中文又乱码。
晕死了。

mimi

unread,
Apr 11, 2008, 9:56:06 PM4/11/08
to SciTE研究 - 中文小组
我也有这种问题,所以写了一个切换编码的 lua 脚本,功能不是很强

欢迎有能力的人进一步开发

使用方法:

在 startup.lua 中加入 require 'enc',重启 SciTE

Ctrl+E 激活编码菜单

ps.文件已经上传到小组文件中

mimi

unread,
Apr 11, 2008, 9:59:49 PM4/11/08
to SciTE研究 - 中文小组
差点忘了 createCommand ('Encoding|encoding|Ctrl+E') 是自己写的函数

请在 require 'enc' 之前加一行 require 'cmd'

同时请把 cmd.lua 和 enc.lua 放到 startup.lua 的 目录下

Danwu Hou

unread,
Apr 11, 2008, 10:06:28 PM4/11/08
to scit...@googlegroups.com
一般我都会把utf-8的文件设置编码为"UTF-8 with BOM"再保存,这样下次Scite就能自动识别utf8了,这个时候打开gbk的文件也能正常
如果对于php或者某些文件不方便设置BOM,因为 这会在文件头加上几个字节的编码标识,可以在文件的前面几行加上类似的内容:
// encoding=utf-8
只要文件的第一第二行含有encoding=xxx的内容,scite就会根据这个编码来显示文件

以下是帮助文件SciTEDoc.html的原文:

Encodings

SciTE will automatically detect the encoding scheme used for Unicode files that start with a Byte Order Mark (BOM). The UTF-8 and UCS-2 encodings are recognized including both Little Endian and Big Endian variants of UCS-2.

UTF-8 files will also be recognised when they contain a coding cookie on one of the first two lines. A coding cookie looks similar to "coding: utf-8" ("coding" followed by ':' or '=', optional whitespace, optional quote, "utf-8") and is normally contained in a comment:
# -*- coding: utf-8 -*-
For XML there is a declaration:
<?xml version='1.0' encoding='utf-8'?>

For other encodings set the code.page and character.set properties.



在08-4-11,scite <hhyy...@gmail.com> 写道:
Reply all
Reply to author
Forward
0 new messages