noophq / subtitle

Convert subtitles from one format to another format. Supported formats: STL EBU, TTML SMI, VTT, SRT
GNU Lesser General Public License v3.0
100 stars 40 forks source link

CRLF & LF #12

Open labmem005 opened 5 years ago

labmem005 commented 5 years ago

A file write with 'CRLF' can't parse. SubtitleParsingException: Unable to parse cue number: 1

clebeaupin commented 5 years ago

Could you provide an sample file containing CRLF ?

labmem005 commented 5 years ago

crlf.srt.zip

missesProper commented 5 years ago

Hi together :-) I do have the same problem - f.i. with the attached srt. src.zip Reason is probably the BOM. Proposal: When doing

// First textLine is the cue number try { Integer.parseInt(textLine); } catch (NumberFormatException e) { throw new SubtitleParsingException(String.format( "Unable to parse cue number: %s", textLine)); }

Use this method to fix textLine: private static String removeUTF8BOM(String s) { if (s != null && s.startsWith(UTF8_BOM)) { s = s.substring(1); } return s; }

with private static final String UTF8_BOM = "\uFEFF";

Sorry if this is not the proper way to contribute, it is my first day at Github - and it is FRIDAY!

labmem005 commented 5 years ago

@missesProper Thank you!get it \^O^/

:octocat: From gitme Android