Liking cljdoc? Tell your friends :D

im.ttalk.agent.tools.text

文本小件:内容 tag、UTF-8 字节截断、「按原样读进来、按原样写回去」的可编辑文本、统一格式 diff。

  • content-tag:FNV-1a 32 位、8 位大写十六进制(出处 Keelson ContentTag.cs, 借鉴 coxswain tag.ss;测试向量 "hello" ⇒ 4F9F2CAB)。是内容哈希不是 mtime—— 「同一秒改成同样长度」正是新鲜度闸要抓的那类。
  • decode-editable / encode-editable:换行 / 编码 / BOM 原样写回,二进制拒绝 (出处 Keelson EditableText.cs)。只认 UTF-8(可带 BOM)、带 BOM 的 UTF-16/32、 严格 GBK(编回去逐字节相同才认);其余拒(⛔ 猜一个写回去)。
  • unified-diff:审批预览用(出处 Keelson PatchDiff.cs 的格式口径,算法用 LCS)。
文本小件:内容 tag、UTF-8 字节截断、「按原样读进来、按原样写回去」的可编辑文本、统一格式 diff。

- `content-tag`:FNV-1a 32 位、8 位大写十六进制(出处 Keelson `ContentTag.cs`,
  借鉴 coxswain `tag.ss`;测试向量 "hello" ⇒ 4F9F2CAB)。是**内容**哈希不是 mtime——
  「同一秒改成同样长度」正是新鲜度闸要抓的那类。
- `decode-editable` / `encode-editable`:换行 / 编码 / BOM 原样写回,二进制拒绝
  (出处 Keelson `EditableText.cs`)。只认 UTF-8(可带 BOM)、带 BOM 的 UTF-16/32、
  严格 GBK(编回去逐字节相同才认);其余拒(⛔ 猜一个写回去)。
- `unified-diff`:审批预览用(出处 Keelson `PatchDiff.cs` 的格式口径,算法用 LCS)。
raw docstring

content-tagclj

(content-tag x)

字节或字符串(按 UTF-8)的 tag。

字节或字符串(按 UTF-8)的 tag。
sourceraw docstring

decode-editableclj

(decode-editable bs shown)

解码一个要改的文本文件;认不出 ⇒ fail!(二进制 / 未知编码)。 返回 {:text 换行统一成 \n 的文本 :eol :charset :bom 原样写回的 BOM 字节 :label}。

解码一个要改的文本文件;认不出 ⇒ fail!(二进制 / 未知编码)。
返回 {:text 换行统一成 \n 的文本 :eol :charset :bom 原样写回的 BOM 字节 :label}。
sourceraw docstring

detect-eolclj

(detect-eol s)

换行风格:只有 CRLF ⇒ :crlf;只有 CR ⇒ :cr;其余(含混合、没有换行)⇒ :lf(混合时多余的 \r 是内容)。

换行风格:只有 CRLF ⇒ :crlf;只有 CR ⇒ :cr;其余(含混合、没有换行)⇒ :lf(混合时多余的 \r 是内容)。
sourceraw docstring

encode-editableclj

(encode-editable {:keys [eol charset bom label]} text shown)

按原来的换行 / 编码 / BOM 编出字节;写不出 ⇒ fail!。

按原来的换行 / 编码 / BOM 编出字节;写不出 ⇒ fail!。
sourceraw docstring

fnv-offsetclj

source

fnv-primeclj

source

normalize-inputclj

(normalize-input {:keys [eol]} s)

模型给的文本 ⇒ 这个文件的换行写法:CRLF / CR 文件先把模型抄来的 \r\n 归一成 \n。

模型给的文本 ⇒ 这个文件的换行写法:CRLF / CR 文件先把模型抄来的 \r\n 归一成 \n。
sourceraw docstring

split-keep-endsclj

(split-keep-ends s)

按 \n 切、每行保留自己的 \n。

按 \n 切、每行保留自己的 \n。
sourceraw docstring

strict-decodeclj

(strict-decode cs bs off)

严格解码;坏字节 ⇒ nil。

严格解码;坏字节 ⇒ nil。
sourceraw docstring

strict-encodeclj

(strict-encode cs s)

严格编码;写不出 ⇒ nil。

严格编码;写不出 ⇒ nil。
sourceraw docstring

tag-appendclj

(tag-append h bs)
(tag-append h bs off len)

从 hash 接着喂 bytes 的 [off, off+len)。流式读文件时用。

从 hash 接着喂 bytes 的 [off, off+len)。流式读文件时用。
sourceraw docstring

tag-formatclj

(tag-format h)
source

take-bytes-at-char-boundaryclj

(take-bytes-at-char-boundary s max-bytes)

超过 max-bytes 个 UTF-8 字节就在字符边界上截(Codex take_bytes_at_char_boundary)。

超过 max-bytes 个 UTF-8 字节就在字符边界上截(Codex take_bytes_at_char_boundary)。
sourceraw docstring

unified-diffclj

(unified-diff old new)
(unified-diff old new context)

旧 ⇒ 新的统一格式差分(没有 ---/+++ 头,hunk 头行数为 1 时省掉;同 Codex 的 similar 口径)。

旧 ⇒ 新的统一格式差分(没有 ---/+++ 头,hunk 头行数为 1 时省掉;同 Codex 的 similar 口径)。
sourceraw docstring

utf8-lenclj

(utf8-len s)
source

utf8-strictclj

(utf8-strict bs)

严格 UTF-8 解码;坏字节 ⇒ nil。

严格 UTF-8 解码;坏字节 ⇒ nil。
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close