我有以下字符串:
index 0 1 2 3 4 5 6 7
std::string myString with the content of "\xff\xff\xff\x00\xff\x0d\x0a\xf5"
当我引用 myString[3] 时,我得到了预期的 '\x00' 值。
但是当我提到 myString[5] 时,我得到了两个值“\x0d\x0a”,而不仅仅是“\x0d”。
更有趣的是 myString[6] 值,即 '\xf5'。这次就像 \x0d 不存在并且引用了正确的位置。
我的问题是:std:string 对象中的 \x0d 字符有什么特别之处?索引时如何跳过它?就像这样计算:
index 0 1 2 3 4 5 5 6
std::string myString = "\xff\xff\xff\x00\xff\x0d\x0a\xf5"
作为注释,'\x0d' 字符是第 13 个 ASCII 字符“回车”,而 '\x0a' 是换行符。
更新: std::string 是否将 "\x0d\x0a" 视为单个字符,因此仅在字符串中占据一个位置?这个 '\x0d' 是关于 std::string 的“神秘”字符吗?