不能在字符串中嵌入非ascii字符
Cannot embed non-ASCII in string
当我尝试在字符串中添加非ascii字符时,g++ (v 4.7.3)给出警告。输出完全出乎意料。'23 00 25 30 ';
#include <stdio.h>
int main(int argc, char *argv[]) {
char *p = "x03123";
printf("%02x %02x %02x %02xn", p[0], p[1], p[2], p[3]);
return 0;
}
I got error
g++ -std=c++11 te2a.cc
te2a.cc: In function ‘int main(int, char**)’:
te2a.cc:5:12: warning: hex escape sequence out of range [enabled by default]
te2a.cc:5:12: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
结果我不得不使用
"x03x30x31x32x33"
或
" x03""123"
猜我被脚本语言(如perl)宠坏了,在那里有"x03123"
是可以的。
相关文章:
- RE2 不匹配非 ASCII 字符
- 打印从 0 到 255 的所有 ASCII 字符
- C++ 电话号码字母拨号程序 - 语法错别字?还是非 ASCII 字符?
- 如何从 QString 中包含的十六进制值中获取 ASCII 字符?
- Cin 和 getline 无法正确保存非 ascii 字符
- C++-将ASCII字符数组中可能的数值转换为字符的最简单方法
- 非ASCII字符的词典排序
- 将char类型指定给int以打印相应的ASCII字符
- 将非 ASCII 字符转换为英语对应字符C++
- 在 C++ 中从 8 位 ASCII 字符创建 7 位 ASCII 文本字符串
- 如何在不将其转换为 ASCII 字符的情况下显示 QByteArray 的十六进制值
- 如何遍历所有 ASCII 字符?
- 在控制台中以C++打印(并存储)高 ASCII 字符 (╔)
- Qt:文件名中的非 ASCII 字符替换为"?"
- ASCII字符时的意外终结
- C 17是否允许非ASCII字符作为标识符
- QML 映像不会在映像源中加载具有非 ASCII 字符的图像
- MFC Cedit将非ASCII字符转换为ASCII
- 如何与C 字符串中的非ASCII字符一起工作
- 使用 c++ 是否可以将 ASCII 字符转换为十六进制?