简体   繁体   English

用 Arduino 显示 Unicode 个字符

[英]Displaying Unicode Characters with Arduino

I am currently using the Keyboard.h library on Arduino我目前在 Arduino 上使用Keyboard.h 库

I would like to display the following characters upon pressing a button on my breadboard: ♥ ♦ ♣ ♠我想在按下面包板上的按钮时显示以下字符:♥ ♦ ♣ ♠

I don't know much about ASCII, Unicode and Hexadecimal so I'm having a hard time figuring this out我不太了解 ASCII、Unicode 和十六进制,所以我很难弄清楚

Does someone know how to do it?有人知道怎么做吗?

Thanks.谢谢。

Try Keyboard.print("\\uUNICODE_VALUE"); 尝试Keyboard.print("\\uUNICODE_VALUE"); Unicode values can be found at: http://www.unicode.org/charts/ Unicode值可以在以下位置找到: http : //www.unicode.org/charts/

If that don't work on linux you can hit Ctrl + Shift + u , type the unicode value, and press enter like this: 如果这在Linux上不起作用,则可以按Ctrl + Shift + u ,输入unicode值,然后按Enter键,如下所示:

void typeUnicode(int val, int time){
    Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.press(KEY_LEFT_SHIFT);
    Keyboard.press('u');
    delay(time);
    Keyboard.releaseAll();
    delay(time);
    Keyboard.println(String(val, HEX));
    delay(time);
}

On Windows you havel "ALT codes", and i'm not sure how they work since i'm a unix geek. 在Windows上,您拥有“ ALT代码”,并且由于我是UNIX极客,所以我不确定它们的工作方式。

See my answer at https://arduino.stackexchange.com/a/91365/70109 for how to convert from unicode to Octal for output请参阅我在https://arduino.stackexchange.com/a/91365/70109的回答,了解如何将 unicode 转换为八进制 output

The GCC compiler used by Arduino also does not accept all unicode sequences such as Using octal avoids this problem. Arduino使用的GCC编译器也不接受所有unicode序列如Using octal避免了这个问题。 在此处输入图像描述

Serial.print("\342\204\211");

will output ℉ provided the receiver has font for that unicode.如果接收器具有 unicode 的字体,将是 output ℉。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM