c - 将多字节存储到 char 数组中
问题描述
以下代码有效:
char *text = "中文";
printf("%s", text);
然后我试图通过它的unicode代码点打印这个文本,它是0x4e2d
“中”和0x6587
“文”:
当然,没有打印出来。
我试图了解当我将多字节字符串存储到这里时发生了什么char*
以及如何使用它的 unicode 代码点打印多字节字符串,此外,“ Format specifier '%ls' requires 'wchar_t *' argument instead of 'wchar_t *'
”是什么意思?
谢谢你的帮助。
编辑:我在 Mac osx (high sierra 10.13.6) 和 clion
$ gcc --version
Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 9.1.0 (clang-902.0.39.2)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
解决方案
推荐阅读
- c# - 如何按部分将 JSON 文件反序列化为 C# 对象
- php - 按钮和表格下拉列表显示 Laravel 8 中的重复值
- kubernetes-helm - helm 语法 {{ something }} 和 {{- something }} 有什么区别?
- sql - 雪花 Where 子句没有过滤?
- java - 为什么这段代码说 x 没有初始化,但是当我们在 if 语句中执行 print 语句时它工作正常?
- javascript - 将对象作为道具传递
- python - 如何使用python从网站中提取所有链接
- discord - 用于将用户添加到频道的 Discord Reaction OR 命令
- socket.io - 带有 WebRTC 的视频聊天应用程序问题与浏览器不显示房间中的其他用户
- angular-slickgrid - 如果我预先选择了所有集合值,Angular slickgrid Multiselect 应该显示“全部”