[MPlayer-dev-eng] [PATCH] Libass BOM fix

Evgeniy Stepanov eugeni.stepanov at gmail.com
Sat Oct 27 13:10:03 CEST 2007


On Saturday 27 October 2007 11:06:51 Ulion wrote:
> Hello,
>
> Some ass/ssa file is utf-16 encoded with a BOM (byte-order marker) as
> the beginning of file.
> While libass did not handle such file correctly, it will fail to load
> such subtitle files.
> This patch fixed this problem. The second file is for testing which is
> an utf-16 encoded ass file.

It might break things if a file in some other encoding starts with 'FFFE' 
or 'FEFF'. Not sure if it can happen. It's probably more safe to only do this 
detection if codepage is already some kind of unicode.

The attached file works fine here, because it is LE and my machine is also LE. 
However, UCS-2BE files indeed cannot be opened without explicit -subcp. The 
problem is, enca detects file encoding as simply 'UCS-2', and iconv does not 
pay attention to BOM.

In fact, enca is able to detect the endianness of unicode files, even without 
a BOM sometimes. This information is available via EncaSurface. It seems a 
good idea to use it, and only do manual detection when not using enca.



More information about the MPlayer-dev-eng mailing list