arduino / arduino/ArduinoCore-API
Arduino String class: features missing (feature request)
- 主要语言
- C++
- 星标
- 306
- 派生
- 150
- PR 合并指标
- 30 天内没有已合并 PR
描述
hi,
for Arduino C++ Strings some features are missing:
.readStringUntil(EOL) or perhaps a new .readln(): to read an entire textline all at once until end of line, discarding any EoL/CR
(e.g., text lines may have \n or \r\n at EoL, so readStringUntil('\n') or readStringUntil('\r') may fail or mess it up)
additionally also helpful:
.insert(substr, pos, len)
.delete(pos, len)
and especially
.TokenArg(token, delimiter1, delimiter2) // edit: optionally also just named .arg()
// returns the value of a token, e.g. for a String containing analog=1234;
`String myArg = myString.TokenArg("analog", "=", ";") ` would return 1234 as a String.
OTOH, IMO .compareTo() is ambiguous, it returns +/-/0 for after/before/ident but completely unclear if or what when neither and they are completely different. Better if it returned NAN/-1/0/+1 for notIn/smaller/ident/bigger.
PS,
just recalled that the WebServer lib provides a method `.arg()` which works somehow like the requested `String.TokenArg()` functionality:
```
int Analog1=0;
String myArg = webserver.arg("analog");
if (myArg != "") {
Analog1 = myArg.toInt();
}
```
That could be also used as a pattern for a String class TokenArg function.
贡献指南
这个仓库没有索引到贡献指南
调研方向
该 issue 提到了 Arduino C++ String 方法,但没有提供文件或测试。首先检查现有的 String 类以及 compareTo/read 的行为,然后与维护者明确所请求的 API 和换行语义。在实现之前,就所提议更改的范围和行为达成一致,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- cpp
- 领域
- embedded-iot
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100