如何从sdl_textinput获取UTF-8输入
How to get utf-8 input from SDL_TEXTINPUT?
这是一个小型代码,当我们按"é"键或特殊字符的特殊字符时,我们会在控制台中获得奇怪的字符,例如"├®"。
#include <iostream>
#include "SDL.h"
using namespace std;
int main(int argc, char** argv)
{
SDL_Init(SDL_INIT_EVERYTHING);
SDL_CreateWindow("test", 100, 100, 1920, 1080, SDL_WINDOW_RESIZABLE);
bool opened = true;
SDL_Event event;
while(opened)
{
SDL_StartTextInput();
SDL_WaitEvent(&event);
switch(event.type)
{
case SDL_QUIT:
{
opened = 0;
break;
}
case SDL_TEXTINPUT:
{
cout << event.text.text << endl;
break;
}
}
}
return EXIT_SUCCESS;
}
ps:我正在使用SDL 2
只需要使用 TTF_RenderUTF8_Blended
进行渲染(文件中的输出很好)。
相关文章:
- C++为构建时间获取QDateTime的可靠方法
- HEX值到wchar_t字符(UTF-8)的转换
- lambda参数转换为constexpr技巧,然后获取带链接的数组
- 如何使用 < 和 > 命令获取 c++ 中的输入和输出?
- 使用指针从C++中的数组中获取最大值
- 如何获取std::result_of函数的返回类型
- 如何在openssl-ecc中获取十六进制格式的私钥
- 使用Unreal C++获取VR耳机的世界位置/方向
- 获取日期异步信号安全吗?如果在信号处理程序中使用,它会导致死锁吗
- 从C字符串中获取奇怪的字符串长度
- 为什么我的for循环不能正确获取argv
- 从python中调用C++函数并获取返回值
- 如何从Little Endian UTF-16编码字节中获取C++std::string
- 在 Linux 中将 UTF-32 宽字符转换为 UTF-16 宽字符以获取补充平面字符
- 如何从sdl_textinput获取UTF-8输入
- 如何从 UTF-8 字符串的每个字符中获取 UNICODE 代码
- 如何从C#中获取UTF-8中的字符串到C DLL
- 如何从文件中写入的UTF-8编码的URDU字符串中获取单个字符
- C++通过 utf-8 值获取 unicode 字符
- 从CreateProcess()中获取UTF-8输出