比较 unicode 和 wchar_t C++:"找不到数字文字运算符"运算符" " F""
Comparing unicode and wchar_t C++ : `unable to find numeric literal operator 'operator""F'`
所以我有一个wchar_t tempc;
. 我想看看它是否在 unicode 范围内 000000-00007F。
这就是我尝试比较值的方式:
if ((tempc < (wchar_t)000000) || (tempc > (wchar_t)00007F)) { ...
我认为这会将 unicode 值 000000 和 00007F 转换为wchar_t。但是我收到以下错误:
error: invalid suffix "F" on integer constant
error: invalid digit "8" in octal constant
error: invalid suffix "FF" on integer constant
error: invalid digit "8" in octal constant
所以很明显,编译器不知道像 00007F 这样的值是如何是 unicode。我在这里有什么误解?我是否先将它们转换为 unicode(如果是这样,如何?),然后再转换为 wchar_t?
在C++中,以 0 开头的常量值是八进制数。因此,它不能包含 8 或 F。十六进制常量应写入0x7F
。只需写:
if ((tempc < (wchar_t)0) || (tempc > (wchar_t)0x7F)) { ...
相关文章:
- 为什么 std::variant 找不到运算符<() 当与比较类不在同一命名空间中时
- 为什么 c++ 编译器找不到运算符<<
- 错误 C2679:二进制'<<':找不到采用类型 'overloaded-function' 的右侧操作数的运算符(或者没有可接受的转换)
- 为什么C++找不到布尔运算符,当有一个!范围内的运算符?
- g++ std::set 找不到运算符<为类定义
- 为什么找不到使用命名空间中定义的类型实例化的 std::weak_ptr 的重载运算符==?
- <<找不到运算符,尽管定义了 Foo 类型的右操作数,但该运算符仍采用类型为 Foo 的右侧操作数
- 类没有合适的复制构造函数,找不到二进制运算符 '=',
- 找不到数字文字运算符“运算符”“+BLA”
- 错误:找不到数字文字运算符"运算符 " " U"?
- 模板 = 找不到运算符
- 错误 C2679:二进制'>':找不到采用类型 'int' 的右侧操作数的运算符(或者没有可接受的转换)
- Arduino IDE告诉我找不到字符串文字运算符“运算符”“DRIVE”
- C++ STL 比较映射找不到(运算符==)
- 错误 C2679:二进制"[":找不到采用右侧操作数的运算符
- 为什么我们在使用宏时找不到合适的运算符重载
- C++ 调试在Visual Studio中找不到'='运算符
- 在自定义双链接列表中的自定义迭代器的取消运算符,找不到二进制操作员
- 错误的任何修复:二进制">>"找不到运算符
- 为什么找不到重载运算符函数?