Skip to content

Commit 497af97

Browse files
committed
use Windows new lines if we are on Windows. Fixes #2
1 parent d6ef084 commit 497af97

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

srt.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@ package subtitles
33
import (
44
"fmt"
55
"regexp"
6+
"runtime"
67
"strconv"
78
"strings"
89
"time"
910
)
1011

1112
// Eol is the end of line characters to use when writing .srt data
12-
const eol = "\n"
13+
var eol = "\n"
14+
func init() {
15+
if runtime.GOOS == "windows" {
16+
eol = "\r\n"
17+
}
18+
}
1319

1420
func looksLikeSRT(s string) bool {
1521
if strings.HasPrefix(s, "1\n") || strings.HasPrefix(s, "1\r\n") {

0 commit comments

Comments
 (0)