nwoltman / srt-to-vtt-cl

A command line tool that converts subtitle files from SubRib (.srt) format to WebVTT (.vtt) format
MIT License
95 stars 11 forks source link

Don't use UTF8 conversion for non-UTF8 encoded files #3

Closed elsnosrap closed 9 years ago

elsnosrap commented 9 years ago

I was recently using this excellent tool to convert a large number of SRT caption files to VTT. A fair amount of them were detected as ANSI encoded. When using the UTF-8 conversion, the files would be truncated at the first accented character it came across. I made the following change which fixed the issue for my files.

I also added some code to print out the file's detected encoding during the conversion process.

I don't have access to a Windows machine, so I've only updated the Mac binary.

nwoltman commented 9 years ago

Thanks for the pull request @mitsnosrap and for bringing this issue to my attention. Could you possibly provide me with the files that were getting cut off so I can test this fix out on my machine?

elsnosrap commented 9 years ago

Sure, I've attached a sample SRT file to a branch in my fork - https://github.com/mitsnosrap/srt-to-vtt-cl/blob/sample-srt/811357016834.swe.srt.

nwoltman commented 9 years ago

Just tested it and everything looks good! Please address those two little things I commented on and I'll get this merged in (I know they're pretty picky things, but it's just to keep the code base consistent).

elsnosrap commented 9 years ago

No worries - I haven't done C/C++ programming in 5+ years, and I work with some people who can be picky. :smile:

nwoltman commented 9 years ago

Awesome! If you're comfortable with squashing commits, could you please squash your 3 commits into 1?

elsnosrap commented 9 years ago

Done!

nwoltman commented 9 years ago

Thanks @mitsnosrap! :+1:

elsnosrap commented 9 years ago

np - happy to contribute to an awesome project! I attempted to get this to compile on Linux this morning, but I fear my C++ skills are too rusty.

nwoltman commented 9 years ago

Yeah compiling on Linux is tough. It requires a recent version of Clang or GCC 5.0+ to compile on Linux, and even then I've had problems with it not finding the right .so libraries.