RE2 不匹配非 ASCII 字符
RE2 Not matching non-ascii characters
我无法让 RE2 使用其十六进制/八进制表示形式匹配字节(不是 ascii(。
下面的代码片段解释了这个问题:
char *test = "abc""xe2""xyz";
std::string str(test); // "abc342xyz" . 342 is octal for xe2
// str.size() == 7
re2::StringPiece string_piece(str); // size is 7, as expected
std::string out;
// extracts the letter 'z' into 'out;. 172 is the octal for z
bool match = re2::RE2::PartialMatch(string_piece, ("(172)"), &out); // match = true, out = 'z'.
// should extract the character 342...but it doesn't.
match = re2::RE2::PartialMatch(string_piece, ("(342)"), &out); // match = false
将编码设置为 latin-1 - RE2 默认值为 UTF-8
match = re2::RE2::P artialMatch(string_piece, re2::RE2("(\342(", re2::RE2::Latin1(, 和出(;
相关文章:
- C++,在int数组中输入字符串或字符会输出0,而不是ascii或error
- 有没有办法通过使用十进制 ASCII 代码自动类型扣除来获取字符?
- RE2 不匹配非 ASCII 字符
- 打印从 0 到 255 的所有 ASCII 字符
- C++ 电话号码字母拨号程序 - 语法错别字?还是非 ASCII 字符?
- 无符号字符打印其 ASCII 值
- 如何从 QString 中包含的十六进制值中获取 ASCII 字符?
- 在结构数据类型中更改每个字符的 ASCII 值
- Cin 和 getline 无法正确保存非 ascii 字符
- C++-将ASCII字符数组中可能的数值转换为字符的最简单方法
- 非ASCII字符的词典排序
- 将char类型指定给int以打印相应的ASCII字符
- 将非 ASCII 字符转换为英语对应字符C++
- 在 C++ 中从 8 位 ASCII 字符创建 7 位 ASCII 文本字符串
- C++ UTF-8 瑞典语字符读取为 ASCII
- 将十六进制字符数组存储在字节数组中,而无需更改为 ASCII 或其他任何东西
- 如何在不将其转换为 ASCII 字符的情况下显示 QByteArray 的十六进制值
- 如何遍历所有 ASCII 字符?
- 读取字符 ASCII 值并将其记录到矢量
- 如何在C++中读取带有ifstream的替换字符?(ASCII 中的 SUB)