Terminal can not output Chinese properly

I found Terminal can not output normal Chinese
This is the code

terminal.println("这是一个测试") ;
terminal.println("This is a test") ;
terminal.println("我发现不能正常的输出中文") ;
terminal.println("I found that normal Chinese can not be output") ;
terminal.println("总是会有一些字符乱码,比如输出的出") ;
terminal.println("There will always be some characters garbled, such as output") ;

This is displayed on the phone

You can see the picture

Seems to be abnormal in some cases, it looks like the data is truncated, leading to incomplete?

After that, I did a lot of experiments for comparison

This is an interesting experiment, through this experiment, I found that improper display of Chinese characters, the arrangement seems to have some laws

You can see that every one of the 19 Chinese characters, there will be a display is not normal.

At present I do not know what is the reason, it should be a data format problem?
Normally we use UTF8 encoding, but Chinese may need GBK encoding.
Currently I have not found a good solution, first feedback here.

Hello. Blynk library works with string as UTF-8. So only UTF-8 is supported at the moment.

@Dmitriy
I understand, then how can we fix some characters output is not normal?
You can see the picture

Seems to be abnormal in some cases, it looks like the data is truncated, leading to incomplete?

My friends, I found an interesting way to solve this problem.
You can see

diamond coated question marks Similar to mine

But we can use it

Blynk.virtualWrite(V1, “我发现不能正常的输出中文\n”);
Blynk.virtualWrite(V1, “我发现不能正常的输出中文\n”);

So I think terminal.println () function still needs to be improved. For example, its buffer may have some bug

@mtrucc you are saying that terminal.println() doesn’t have same output as Blynk.virtualWrite?

@Dmitriy I just did a bit of experimentation, I’ve solved the problem, here’s the code:

Blynk.virtualWrite(V1,"这是一个测试\n") ;
Blynk.virtualWrite(V1,"This is a test\n") ;
Blynk.virtualWrite(V1,"我发现不能正常的输出中文\n") ;
Blynk.virtualWrite(V1,"I found that normal Chinese can not be output\n") ;
Blynk.virtualWrite(V1,"总是会有一些字符乱码,比如输出的出\n") ;
Blynk.virtualWrite(V1,"There will always be some characters garbled, such as output\n") ;

This code can be used normally, I think the current terminal.println () function may not be perfect. I hope later to improve this function.
If you can not use terminal.println normally, you can use the Blynk.virtualWrite function

My programming is not very good. English is not very good. But I like blynk very much. I expect to be able to help more friends using blynk.

If I do something wrong, you can reply me, thank you!

3 Likes

@Dmitriy Yes, the output is different

Thanks for updating. I created ticket - https://github.com/blynkkk/blynk-library/issues/372

Hope this helps you. I have updated the status as resolved

1 Like