Reading srt (subtitle) files with Python3?

You could use the chardet package from the Universal Feed Parser to detect the encoding.

You can check for the byte order mark at the start of each . Srt file to test for encoding. However, this probably won't work for all files, as it is not a required attribute, and only specified in UTF files anyways.

A check can be performed by testStr = b'\xff\xfeOtherdata' if testStr0:2 == b'\xff\xfe': print('UTF-16 Little Endian') elif testStr0:2 == b'\xfe\xff': print('UTF-16 Big Endian') #... What you probably want to do is simply open your file, then decode whatever you pull out of the file into unicode, deal with the unicode representation until you are ready to print, and then encode it back again. See this talk for some more information, and code samples that might be relevant.

Thanks brc! How does one establish if the bom is present for a given file using python and how does one print the data associated with this bom? – Baz Sep 20 at 17:41 I've edited the answer to include a sample – brc Sep 20 at 23:40.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions