utils

package
v0.7.10 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const ThinkingSep = "\x02"

ThinkingSep 是思考文本与正文之间的分隔标记。 observer 在思考文本段前插入此标记,TUI 据此切换渲染样式。

Variables

This section is empty.

Functions

func CleanInputLine added in v0.3.0

func CleanInputLine(s string) string

CleanInputLine 清洗单行人工输入,并去掉首尾空白。

func CleanInputRunes added in v0.3.0

func CleanInputRunes(runes []rune) string

func CleanInputText added in v0.3.0

func CleanInputText(s string) string

CleanInputText 删除终端输入中没有业务意义的控制字符,保留用户可见文本。 单行输入场景下,粘贴文本里的换行和制表符会被归一为空格。

func ContainsControl added in v0.3.0

func ContainsControl(s string) bool

func DecodeText added in v0.5.0

func DecodeText(data []byte) string

DecodeText 把用户提供的文本文件字节解码为 UTF-8:非法 UTF-8 时按 GB18030 (GBK 超集)转码——网络流传的中文小说 txt 大量为 GBK 编码,直接当 UTF-8 读 全是乱码。非 GBK 的字节序列会被解码器替换为 U+FFFD(本就是乱码,由调用方的 零命中兜底报错引导用户)。最后剥离 UTF-8 BOM(否则行首匹配会带上它)。

func TruncateRunes added in v0.7.10

func TruncateRunes(s string, n int) string

TruncateRunes 按 rune 截断并补省略号;n 以内原样返回。

Types

This section is empty.

Jump to

Keyboard shortcuts

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