在哪里可以找到提供 String.substring() 方法的库?

Where can I find the library that provides String.substring() method?

我正在尝试在 Linux 上编译一个 Arduino 项目,抽象出硬件部分。考虑以下行:

int keyNumRepeat = userInputPrev.substring(6, 8).toInt();

看起来 Arduino 使用了一些非标准库,我的系统上没有:

hsldz_totp_lock/hsldz_totp_lock.ino:335:38: error: ‘String’ {aka ‘class std::__cxx11::basic_string<char>’} has no member named ‘substring’; did you mean ‘substr’?
  335 |     int keyNumRepeat = userInputPrev.substring(6, 8).toInt();
      |                                      ^~~~~~~~~
      |                                      substr
make: *** [Makefile:54: sim] Error 1

它是否在某个地方可用,以便我可以在尝试编译时将它包含在我的项目中?或者它是否在很大程度上取决于其他 Arduino 实现细节?

Arduino 似乎有一个自定义实现 String

由于它是开源的,所以这里是 header and class files. I only skimmed through them, but they don't appear to be heavily dependent on the rest of the Arduino core API

也就是说,您最好用标准 c++ 替换它们的实现。特别是如果它们只是改善生活质量。使用 string::substr and std::stoi 的等效代码应该是:

int keyNumRepeat = std::stoi(userInputPrev.substr(6, 8));