Hi Zhao,
Not sure what the ideal way to do it is, but here are some examples to get you started:
// some examples for printing UTF-8 characters, sford
// - worked on Mac "screen" and PC "putty", but not PC "teraterm"
#include "mbed.h"
#pragma import(__use_utf8_ctype)
#include "wchar.h"
int main() {
printf("How to print UTF-8 chinese characters...\n");
printf("Like this: %lc%lc%lc%lc%lc%lc\n",0x4f60, 0x597d, 0x4f60, 0x597d, 0x4f60, 0x597d);
wprintf(L"Or like this: \u4f60\u597d\u4f60\u597d\u4f60\u597d\n");
}
The program is at: http://mbed.org/users/simon/published/c24f1f54ddd3691c476667f60872ea29/utf8.zip if you want to import it.
It worked on screen with th -U switch, and putty with the setting changed to UTF-8 mode, but not teraterm for some reason (even though it states it supports UTF-8).
Hope this helps. Tell us how you get on and if you learn any more.
Simon
hello everyone!
like topic say"how to Chinese output by serial",mbed IDE can not input anther lanuage except english,but I only want to get ascii or unicode to output. but I failed.
for example ,I can got unicode for "你好" that is "\u4f60\u597d\u4f60\u597d\u4f60\u597d",if I "printf("\u4f60\u597d\u4f60\u597d\u4f60\u597d") ;" on my PC,it can output "你好". but the same way like "serial_printf("\u4f60\u597d\u4f60\u597d\u4f60\u597d");" on my mbed can only output "?????".
I think there is different between PC and mbed. but how can I get the Chinese ASCII or UNICODE. can output Chinese.
best regards.