Hello forum users. I am having a problem with Cyrillic characters. When launching the application on the android, gibberish will turn out. Someone knows how to fix it.
Здравствуйте форумчане. У меня возникла проблема с кириллическими символами. При запуски приложения на андройд получается тарабарщина. Кто нибудь знает как исправить.
Hi @dron3903
Download a font here, and try this code.
The name of the font and extension must be exact. Also capital letters.
PFont myFont;
void setup() {
size(200, 200);
background(255);
myFont = createFont("CYRIL1.TTF", 28);
fill(0);
textFont(myFont);
textAlign(CENTER);
println(("Привет мир");
}
void draw() {
text("Привет мир", width/2, height/2);
}
if
text(“Привет мир”, width/2, height/2);
wrong text, else…
text(“Ghbdtn vbh”, width/2, height/2);
all ok.
WTF?
What Android version in which language are you using, and what wrong text do you get with the code above?
Unfortunately, I can’t insert a screen from my phone.
Android 10
PDE 3.5.3
Why this string dont work?
char ch = ‘Б’;
text((int)ch,100,100);
1. ERROR in C:\Users\Sys\AppData\Local\Temp\android4479333281688038184sketch\app\src\main\java\processing\test\sketch_201018b\sketch_201018b.java (at line 30)
char ch = 'Р‘';
^^^^
Invalid character constant
----------
1 problem (1 error)
> Task :app:compileDebugJavaWithJavac FAILED
FAILURE: Build failed with an exception.
* Where:
Build file 'C:\Users\Sys\AppData\Local\Temp\android4479333281688038184sketch\app\build.gradle' line: 71
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Process 'command 'C:\prog\processing-3.5.3-windows64\processing-3.5.3\java\bin\java.exe'' finished with non-zero exit value -1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
```![Screenshot_20201018-132830|230x500](upload://8tykSqLSFS3gsiiFy1JrOieBgN1.jpeg)
The error is because the apostrophe or single quote is the wrong one. The text will be red-colored in the IDE f it’s used properly.
A lot of my codes are not working on my new phone with Android 10. Even the first code crashes when loading this font. Strangely using the system font, displays the text well now.
So now I have a lot of work to do.
I get the value 1041 from your char btw.
That’s the trouble. I know the symbols I need. For instance …
text (char (1041), 100,100);
This is how it works, displays “Б” text (‘Б’, 100,100); does not work and can not find out the number of the symbol to fix it.
And text (‘Б’, 100,100); does not work on other Android versions.
I’m using APDE on Android 10, and this code doesn’t give any error.
void draw() {
text ('Б', 100,200);
text (int('Б'), 100, 260);
}
I’ve just tested the same code on a Lollipop (5.1) device, and it works also. (with APDE).
Do you have a real device or emulator? What system language is installed?
I use the app APDE (on Play Store), it is the Processing for Android core directly on your device., and compiles in seconds.
Language on my devices is Portuguese.
Still, a problem in the PDE environment. Starting with some version, I stopped supporting the Cyrillic alphabet on the android. I had to make a crutch, create an XML file and fill in texts from my phone. In what encoding to translate the Cyrillic PDE and how to fix it, I could not find out.
I have the same problem with Cyrillic chars on Android.(Processing for Android mode on Windows)
Just in case this is related:
I’m not from the Cyrillic-writing part of the world, but in the past I had trouble sharing sketches from my phone (APDE) and my computer (processing for windows in android mode). It seemed that sketches saved in android, saved in a git repository and opened in windows garbled non-US characters as “Á” or “€”.
I haven’t tested with current version.
I made a forum entry (or maybe a bugzilla entry) about that in the past:
This is the case when you optimize that one thing and another falls off. It’s a pity.
You may want to store the character in a text file. This way depending on the system you could simply exchange the offending chars without the recourse to the Internet.
After some programming in not-processing java, I found I should use CHCP 65001 before running gradle.
Gradle assumes java files use the current system codepage, so it uses iso-8858-something instead of utf-8.
In the other hand, APDE uses UTF-8 because android runs on top of linux.
The usage of an external text file could be useful, also.
I have to mend my reply.
Best approach is adding/uncommenting this line in gradle.properties:
org.gradle.jvmargs=-Dfile.encoding=UTF8
Substitue UTF8 by the encoding you are using.