go-eol/readnel.go

25 lines
709 B
Go
Raw Normal View History

2023-11-27 19:32:08 +00:00
package eol
import (
"io"
2023-11-28 16:09:19 +00:00
"sourcecode.social/reiver/go-opt"
2024-02-18 17:09:29 +00:00
"sourcecode.social/reiver/go-eol/nel"
2023-11-27 19:32:08 +00:00
)
2023-11-28 16:29:07 +00:00
// ReadNEL tries to read the "\u0085" (i.e., next-line) end-of-line sequence.
//
// If successful, it returns the number-of-bytes read (to read in end-of-line sequence "\u0085").
//
// If the character read is not a '\u0085', then ReadNEL will try to unread the character.
//
// Example usage:
//
// size, err := eol.ReadNEL(runescanner)
2023-11-27 19:32:08 +00:00
func ReadNEL(runescanner io.RuneScanner) (size int, err error) {
2023-11-28 16:09:19 +00:00
const characterNumber uint64 = 1
2024-02-18 17:27:47 +00:00
var circumstance internalCircumstance = specifyCircumstance(opt.Something(nel.String), characterNumber)
2024-02-18 17:09:29 +00:00
return readthisrune(circumstance, runescanner, nel.Rune)
2023-11-27 19:32:08 +00:00
}