diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:53:54 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-09-14 23:53:54 +0200 |
| commit | 0b155e8df3205aebf129091b517f4116665a5adc (patch) | |
| tree | 2215aa05b1d703f9b37badd96aa94a95fd2b14bf /internal/extract/plain.go | |
| parent | 1f1a303c617057f149b4f0d748ee0a195484642c (diff) | |
| download | krino-0b155e8df3205aebf129091b517f4116665a5adc.tar.gz krino-0b155e8df3205aebf129091b517f4116665a5adc.zip | |
main excludes checked with the defaults' case and fold; Latin-1 decoding memory; hardlink election documented
Diffstat (limited to 'internal/extract/plain.go')
| -rw-r--r-- | internal/extract/plain.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/internal/extract/plain.go b/internal/extract/plain.go index 3f04c7e..ce9dedc 100644 --- a/internal/extract/plain.go +++ b/internal/extract/plain.go @@ -142,13 +142,15 @@ func decodeUTF16(b []byte, order binary.ByteOrder) string { } // decodeLatin1 decodes b as Latin-1: each byte is its own Unicode code -// point. +// point. Built directly as UTF-8 (at most two bytes per input byte), not +// through a []rune of four bytes per input byte (triage 28d). func decodeLatin1(b []byte) string { - r := make([]rune, len(b)) - for i, c := range b { - r[i] = rune(c) + var s strings.Builder + s.Grow(len(b) * 2) + for _, c := range b { + s.WriteRune(rune(c)) } - return string(r) + return s.String() } // stripMarkup turns decoded HTML/XML/SVG text into plain text: a small |
