text

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package text ports upstream packages/coding-agent/src/utils/text.ts: the leading byte order mark helpers every Pi reader applies before parsing user-authored JSON, markdown, and text files.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func QuoteUTF16

func QuoteUTF16(units []uint16) []byte

Ports packages/coding-agent/src/modes/rpc/jsonl.ts (JSON.stringify string encoding). QuoteUTF16 returns a JSON.stringify-compatible string token, preserving lone UTF-16 units as escapes instead of replacing them with U+FFFD. It does not apply HTML escaping.

func SplitBom

func SplitBom(content string) (mark, text string)

SplitBom splits a leading UTF-8 byte order mark from decoded text. It returns the mark ("" when absent) and the remaining text. Mirrors upstream splitBom.

func StripBom

func StripBom(content string) string

StripBom removes a leading UTF-8 byte order mark from decoded text. Mirrors upstream stripBom.

func StripBomBytes

func StripBomBytes(content []byte) []byte

StripBomBytes is StripBom for file contents read as bytes, so JSON readers can strip the mark before decoding without a string round trip.

func UTF16Units

func UTF16Units(value string) []uint16

UTF16Units converts Go strings to JavaScript string units. WTF-8 carries lone surrogates without collapsing them into replacement characters; other malformed UTF-8 follows Go's replacement-character decoding.

Types

This section is empty.

Jump to

Keyboard shortcuts

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