length, substr, index and . count bytes, not characters, in a UTF-8 locale
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
调研方向
Start with the byte-based string functions in interpreter/src/builtins.rs and the locale handling in lexer/src/locale_encoding.rs; then trace how regular expressions handle character positions. Check the existing tests for length, substr, index, and regex matching. Done means UTF-8 locales count characters and preserve valid UTF-8, while LC_ALL=C retains byte behavior.
由索引模型根据 Issue 内容生成。
描述
In a UTF-8 locale, string functions and regexps treat each byte as a character:
$ echo héllo | awk '{print length($0), index($0, "l"), substr($0, 2, 1)}'
6 4 �
$ echo héllo | awk '/^.....$/ {print "five"}'
$ echo héllo | awk '{print toupper($0)}'
HéLLO
gawk 5.3.2 prints 5 3 é, five and HÉLLO. POSIX defines these in characters, and substr here cuts é in half, so the output is not valid UTF-8. With LC_ALL=C, gawk counts bytes too (6).
length, substr, index work on bytes in interpreter/src/builtins.rs, and the regex is byte based. The lexer already reads the locale for \u escapes (lexer/src/locale_encoding.rs), so the locale is known.
Is character semantics in a UTF-8 locale planned? I can send a PR for the string built-ins if you want it.
Checked on main 67e0816, LANG=en_US.UTF-8.
- 主要语言
- Rust
- 星标
- 31
- 派生
- 13
- 平均合并
- 23 小时 42 分钟
- 30 天内合并 PR
- 29
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
uutils/awk 的其他 Issue
-
bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
bug crash gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复
-
bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复
-
bug gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
awk: `-f missing-file` and `--source` panic可能已有人在做 @VanshajPoonia 于 4 天前认领。 未关闭bug crash gnu-compat good first issue
难度 2/5 1-3 小时 新手友好度 80/100
维护者通常 1 天内回复
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复
-
code-quality parser
难度 2/5 1-3 小时 新手友好度 88/100
eventflux-io/eventflux#218 ·
维护者通常 1 天内回复
-
StartSso docs say an option requires the built-in AuthnRequest renderer, which is now the only one未关闭documentation needs-triage
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
marketing
难度 2/5 半天 新手友好度 62/100
维护者通常 1 天内回复