是否应该使用utf-8 bom——因DirectVobSub不支持utf-8 no bom带来的问题
2010-01-08 17:33
555 查看
使用DirectVobSub作为播放器的字幕插件。
把字幕转换成utf-8 no bom格式,播放时字幕显示乱码。
把字幕转换成utf-8 bom格式,播放时字幕正常。
看来DirectVobSub不支持utf-8 no bom。
DirectVobSub(vsfilter)官方网站:http://sourceforge.net/projects/guliverkli2/files/DirectShow%20Filters/
utf-8应不应该使用bom呢? unicode标准是如何规定的?
查了一下,供参考:
http://zh.wikipedia.org/zh-cn/UTF-8#UTF-8.E7.9A.84.E8.A1.8D.E7.94.9F.E7.89.A9
维基百科说:
虽然不是标准,但许多Windows 程序(包括Windows 笔记本)在UTF-8编码的文件的开首加入一段字节串EF BB BF。这是字节顺序记号 U+FEFF 的 UTF-8 编码结果。对于没有预期要处理UTF-8的文本编辑器和浏览器会显示成 ISO-8859-1 字符串 ""。
从维基百科的说法看,好像是不应该使用bom。
本着“微软靠得住,母猪会上树” 的成见,由于Windows的记事本另存为utf-8格式会产生bom,而gedit会产生utf-8 no bom,我认为utf-8不应该使用bom。
然后查到http://unicode.org/faq/utf_bom.html#bom1
unicode.org说:
Q: How I should deal with BOMs?
A: Here are some guidelines to follow:
A particular protocol (e.g. Microsoft conventions for .txt files) may require use of the BOM on certain Unicode data streams, such as files. When you need to conform to such a protocol, use a BOM.
Some protocols allow optional BOMs in the case of untagged text. In those cases,
Where a text data stream is known to be plain text, but of unknown encoding, BOM can be used as a signature. If there is no BOM, the encoding could be anything.
Where a text data stream is known to be plain Unicode text (but not which endian), then BOM can be used as a signature. If there is no BOM, the text should be interpreted as big-endian.
Some byte oriented protocols expect ASCII characters at the beginning of a file. If UTF-8 is used with these protocols, use of the BOM as encoding form signature should be avoided.
Where the precise type of the data stream is known (e.g. Unicode big-endian or Unicode little-endian), the BOM should not be used. In particular, whenever a data stream is declared to be UTF-16BE, UTF-16LE, UTF-32BE or UTF-32LE a BOM must not be used. See also [ Q: What is the difference between UCS-2 and UTF-16?] [AF] & [MD]
明白了,我的理解是:
当纯文本文件没有声明编码时,使用bom。如果没有bom,编码不好判断。
如果数据声明了编码,如保存在数据库中的数据(在数据库中声明了编码) 、xml(使用encoding="utf-8"声明编码)、html(使用charset=utf-8声明编码),不应使用bom(the BOM should not be used)。
由此可得,在纯文本中使用utf-8 bom是可以的。
突然想起,以前在linux下使用各个播放器(mplayer、smplayer) 都出现utf-8格式字幕乱码的问题,难道是因为linux下的文本编辑器(gedit等)生成的是utf-8 no bom ?
http://blog.csdn.net/fmddlmyy/archive/2005/05/04/372148.aspx
How I should deal with BOMs?
http://unicode.org/faq/utf_bom.html#bom1
字节顺序记号(英:byte-order mark,BOM)
http://zh.wikipedia.org/zh-cn/%E4%BD%8D%E5%85%83%E7%B5%84%E9%A0%86%E5%BA%8F%E8%A8%98%E8%99%9F
把字幕转换成utf-8 no bom格式,播放时字幕显示乱码。
把字幕转换成utf-8 bom格式,播放时字幕正常。
看来DirectVobSub不支持utf-8 no bom。
DirectVobSub(vsfilter)官方网站:http://sourceforge.net/projects/guliverkli2/files/DirectShow%20Filters/
utf-8应不应该使用bom呢? unicode标准是如何规定的?
查了一下,供参考:
http://zh.wikipedia.org/zh-cn/UTF-8#UTF-8.E7.9A.84.E8.A1.8D.E7.94.9F.E7.89.A9
维基百科说:
虽然不是标准,但许多Windows 程序(包括Windows 笔记本)在UTF-8编码的文件的开首加入一段字节串EF BB BF。这是字节顺序记号 U+FEFF 的 UTF-8 编码结果。对于没有预期要处理UTF-8的文本编辑器和浏览器会显示成 ISO-8859-1 字符串 ""。
从维基百科的说法看,好像是不应该使用bom。
本着“微软靠得住,母猪会上树” 的成见,由于Windows的记事本另存为utf-8格式会产生bom,而gedit会产生utf-8 no bom,我认为utf-8不应该使用bom。
然后查到http://unicode.org/faq/utf_bom.html#bom1
unicode.org说:
Q: How I should deal with BOMs?
A: Here are some guidelines to follow:
A particular protocol (e.g. Microsoft conventions for .txt files) may require use of the BOM on certain Unicode data streams, such as files. When you need to conform to such a protocol, use a BOM.
Some protocols allow optional BOMs in the case of untagged text. In those cases,
Where a text data stream is known to be plain text, but of unknown encoding, BOM can be used as a signature. If there is no BOM, the encoding could be anything.
Where a text data stream is known to be plain Unicode text (but not which endian), then BOM can be used as a signature. If there is no BOM, the text should be interpreted as big-endian.
Some byte oriented protocols expect ASCII characters at the beginning of a file. If UTF-8 is used with these protocols, use of the BOM as encoding form signature should be avoided.
Where the precise type of the data stream is known (e.g. Unicode big-endian or Unicode little-endian), the BOM should not be used. In particular, whenever a data stream is declared to be UTF-16BE, UTF-16LE, UTF-32BE or UTF-32LE a BOM must not be used. See also [ Q: What is the difference between UCS-2 and UTF-16?] [AF] & [MD]
明白了,我的理解是:
当纯文本文件没有声明编码时,使用bom。如果没有bom,编码不好判断。
如果数据声明了编码,如保存在数据库中的数据(在数据库中声明了编码) 、xml(使用encoding="utf-8"声明编码)、html(使用charset=utf-8声明编码),不应使用bom(the BOM should not be used)。
由此可得,在纯文本中使用utf-8 bom是可以的。
突然想起,以前在linux下使用各个播放器(mplayer、smplayer) 都出现utf-8格式字幕乱码的问题,难道是因为linux下的文本编辑器(gedit等)生成的是utf-8 no bom ?
参考资料:
谈谈Unicode编码,简要解释UCS、UTF、BMP、BOM等名词http://blog.csdn.net/fmddlmyy/archive/2005/05/04/372148.aspx
How I should deal with BOMs?
http://unicode.org/faq/utf_bom.html#bom1
字节顺序记号(英:byte-order mark,BOM)
http://zh.wikipedia.org/zh-cn/%E4%BD%8D%E5%85%83%E7%B5%84%E9%A0%86%E5%BA%8F%E8%A8%98%E8%99%9F
相关文章推荐
- WCF热门问题编程示例(3):WCF是否使用或者支持IOCP完成端口(整理补充)
- 用SecurAble检测cpu是否支持Intel VT虚拟化技术的LOCKED ON,LOCKED OFF,YES,NO使用说明
- 中文乱码问题 ? 原因:JSP中默认使用iso-8859-1字符编码方式,不支持中文 ? 常见的支持中文的编码方式:gb2312(常用简体汉字)、gbk(简体和繁体汉字)、utf-8 ? 解决中文乱码
- WCF热门问题编程示例(3):WCF是否使用或者支持IOCP完成端口(整理补充)
- myeclipse 编码设置及乱码问题(项目开始时,应该检查一下设置是否都为UTF-8编码格式,以防止中文乱码问题).
- WCF热门问题编程示例(3):WCF是否使用或者支持IOCP完成端口(整理补充)
- 用SecurAble检测cpu是否支持Intel VT虚拟化技术的LOCKED ON,LOCKED OFF,YES,NO使用说明
- ajax php bomt头 utf-8带来的奇怪问题。。返回值false 判断也是false 但是判断错误
- WCF热门问题编程示例(3):WCF是否使用或者支持IOCP完成端口(整理补充)
- PHP 使用流方式下载文件与 UTF-8 的 BOM 问题
- WordPress主题文件UTF-8 BOM带来的问题及解决方法
- [问题大概解决了,应该就是单键模式使用不当产生的。明天找人来做一下压力测试]又一次斗胆发到了首页。期盼帮我检查下objDB类是否有问题
- 使用prototype.js 的时候应该特别注意的几个问题.
- 使用CInternetSession获取utf-8页面中文乱码问题解决方法
- 使用Flash上传应该注意的问题。
- 使用clone解决hibernate+spring集成中的延迟加载问题及分析(no session or session was closed)
- 关于使用汇编所想到的……IT公司企业文化和实力的问题,看看它的技术支持就可见一斑
- 判断某个问题是否适合使用ForkJoin解决
- 类的Map属性在使用中应该注意的问题
- 在Android中使用HttpClient 4.3.x出现NoSuchFieldError的问题