File: version_agnostic.go

package info (click to toggle)
golang-github-apparentlymart-go-textseg 13.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,120 kB
  • sloc: ruby: 205; makefile: 3
file content (28 lines) | stat: -rw-r--r-- 1,111 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package textseg

// The functions in this file are not currently specific to a given version of
// go-textseg and so we just call into the version from the latest upstream
// major version in all cases.

import (
	"bufio"

	realImpl "github.com/apparentlymart/go-textseg/v12/textseg"
)

// ScanUTF8Sequences is a split function for bufio.Scanner that splits on UTF8 sequence boundaries.
//
// This is included largely for completeness, since this behavior is already built in to Go when ranging over a string.
func ScanUTF8Sequences(data []byte, atEOF bool) (int, []byte, error) {
	return realImpl.ScanUTF8Sequences(data, atEOF)
}

// TokenCount is a utility that uses a bufio.SplitFunc to count the number of recognized tokens in the given buffer.
func TokenCount(buf []byte, splitFunc bufio.SplitFunc) (int, error) {
	return realImpl.TokenCount(buf, splitFunc)
}

// AllTokens is a utility that uses a bufio.SplitFunc to produce a slice of all of the recognized tokens in the given buffer.
func AllTokens(buf []byte, splitFunc bufio.SplitFunc) ([][]byte, error) {
	return realImpl.AllTokens(buf, splitFunc)
}