filter

package
v0.0.0-...-4efc8f3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: BSD-3-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CrTrimModeNone        = iota // 遇到单个 \r 时,不做处理
	CrTrimModeOnlyCr             // 遇到单个 \r 时,只清除 \r
	CrTrimModeBeginOfLine        // 遇到单个 \r 时,清除 \r 及其左侧的内容,直到行首
)

Variables

View Source
var DefaultOptions = Options{
	Crlf:        true,
	CrTrimMode:  CrTrimModeBeginOfLine,
	Backspace:   true,
	AnsiEscape:  true,
	Utf8Replace: true,
}

Functions

This section is empty.

Types

type DefaultFilter

type DefaultFilter struct {
	// contains filtered or unexported fields
}

DefaultFilter 默认字符过滤器

func (DefaultFilter) Do

func (f DefaultFilter) Do(src []byte) []byte

type IFilter

type IFilter interface {
	// Do 过滤字符, 返回过滤后的字符, 不修改源数据
	Do(s []byte) []byte
}

func NewDefaultFilter

func NewDefaultFilter(opt ...Options) IFilter

type Options

type Options struct {
	Crlf        bool // 是否处理回车、换行
	CrTrimMode  int  // 回车字符剔除模式,仅在Crlf为true时有效,默认值 CrTrimModeBeginOfLine,部分设备可能会误删除内容,可设置为 CrTrimModeOnlyCr
	Backspace   bool // 是否处理退格
	AnsiEscape  bool // 是否处理ANSI转义字符
	Utf8Replace bool // 是否处理UTF8替换字符
}

func (Options) IsNothingToDo

func (o Options) IsNothingToDo() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL