initial commits
parent
e44c899fa3
commit
a418be929b
16
consts.go
16
consts.go
|
@ -1,16 +1,16 @@
|
||||||
package eol
|
package eol
|
||||||
|
|
||||||
const (
|
const (
|
||||||
lf = '\u000A'
|
lf = '\u000A'
|
||||||
cr = '\u000D'
|
cr = '\u000D'
|
||||||
nl = '\u0085'
|
nel = '\u0085'
|
||||||
ls = '\u2028'
|
ls = '\u2028'
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
LF = string(lf)
|
LF = string(lf)
|
||||||
CR = string(cr)
|
CR = string(cr)
|
||||||
CRLF = CR+LF
|
CRLF = CR+LF
|
||||||
NL = string(nl)
|
NEL = string(nel)
|
||||||
LS = string(ls)
|
LS = string(ls)
|
||||||
)
|
)
|
||||||
|
|
12
readeol.go
12
readeol.go
|
@ -8,11 +8,11 @@ import (
|
||||||
//
|
//
|
||||||
// The end-of-line sequences it supports are:
|
// The end-of-line sequences it supports are:
|
||||||
//
|
//
|
||||||
// line-feed (LF) (U+000A) ('\n')
|
// line-feed (LF) (U+000A) ('\n')
|
||||||
// carriage-return (CR) (U+000D) ('\r')
|
// carriage-return (CR) (U+000D) ('\r')
|
||||||
// carriage-return, line-feed ("\r\n")
|
// carriage-return, line-feed ("\r\n")
|
||||||
// new-line (NL) (U+0085)
|
// next-line (NEL) (U+0085)
|
||||||
// line-separator (LS) (U+2028)
|
// line-separator (LS) (U+2028)
|
||||||
//
|
//
|
||||||
// If successful, ReadEOL return the end-of-line sequence and the number-of-bytes read.
|
// If successful, ReadEOL return the end-of-line sequence and the number-of-bytes read.
|
||||||
func ReadEOL(runescanner io.RuneScanner) (endofline string, size int, err error) {
|
func ReadEOL(runescanner io.RuneScanner) (endofline string, size int, err error) {
|
||||||
|
@ -37,8 +37,8 @@ func ReadEOL(runescanner io.RuneScanner) (endofline string, size int, err error)
|
||||||
return LF, size0, nil
|
return LF, size0, nil
|
||||||
case cr:
|
case cr:
|
||||||
// Nothing here.
|
// Nothing here.
|
||||||
case nl:
|
case nel:
|
||||||
return NL, size0, nil
|
return NEL, size0, nil
|
||||||
case ls:
|
case ls:
|
||||||
return LS, size0, nil
|
return LS, size0, nil
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -35,7 +35,7 @@ func TestReadEOL(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: "\u0085",
|
Value: "\u0085",
|
||||||
ExpectedEOL: eol.NL,
|
ExpectedEOL: eol.NEL,
|
||||||
ExpectedSize: 2,
|
ExpectedSize: 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -63,7 +63,7 @@ func TestReadEOL(t *testing.T) {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Value: "\u0085apple banana cherr",
|
Value: "\u0085apple banana cherr",
|
||||||
ExpectedEOL: eol.NL,
|
ExpectedEOL: eol.NEL,
|
||||||
ExpectedSize: 2,
|
ExpectedSize: 2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue