I have added some Hindi characters in Unicode to a Java program. Eclipse has no trouble with it, and can run this code, but Gradle keeps crashing - apparently this is due to javac making assumptions about character sets.
I believe I could handle this by converting my whole source directory to Unicode, and specifying encoding as "unicode" in the build.gradle file.
a) is there an official converter, and b) if so, how can I drive it from the build.gradle file?
The program in question is at https://github.com/jpaulm/drawfbp/blob/master/src/main/java/com/jpaulmorrison/graphics/MyFontChooser.java - line 272. Strangely, Gradle has no trouble with the Chinese characters at line 286, so why does only Hindi have problems? Help would be much appreciated!
This is embarrassing! I had one segment in Russian and another in Hindi (Devanagari), the former in ASCII, the latter in Unicode. I assumed my problem was with the Hindi, but it was actually with the Russian! When I converted the Russian to Unicode, everything worked fine (both Eclipse and Gradle)! Abject apologies! I guess we can close this one!
Related
IntelliJ IDEA incorrect encoding in console output
https://www.jetbrains.com/help/idea/encoding.html
Turkish characters are not supported in intellij idea's terminal after run command.
I tried the above two links but I couldn't solve the problem.
console output photo-screenshot
Here is a related issue on YouTrack:
https://youtrack.jetbrains.com/issue/IDEA-291006/Running-the-Java-project-by-using-the-JDK-18-prints-the-garbled-
Feel free to watch it in order to be notified once it has updates. See this article if you are not familiar with YouTrack.
For turkish character support, you chould choose the international global UTF-8 format.
In IntelliJIdea
**File / Settings / Editor / File Encoding** / *.properties
Choose -> **Default encoding for properties files UTF-8
By the use of BOM configurations you can find the correct solution for your files. Do not forget that some choices of BOM for some class files can cause various \uxxxx errors like '\ufeff' error
Moreover you could choose also Global Encoding and Project encoding values just given above in the same tab as UTF-8 to get a more general solution for the future projects.
Screenshot of the web content created by the use of many components bfrom messages.properties
printed text or response from local server with turkish characters
Settings Page
I'm trying to compile an android translator app from GitHub (Link of the App) which is about 4 years old project. I have upgraded its dependencies to androidx API 29 also dependent modules i.e. OpenCV, configured OpenCV 3.4.3. For all modules, I have set minSdkVersion to 14 or above and compile & target SDK version is now 29. Everything seems to work But its showing error for character encoding.
As its translator app, it converts characters of different languages to ASCII. For that, it has a class named Asciify.java (Asciify.java file link). The character set of this file, as well as other files, is UTF-8. But the Android Studio gives an error
error: unmappable character for encoding Cp1252
I search over the internet and read some articles/answers that suggested to change the encoding to compatible encoding. I tried to change the character set to windows-1252, US-ASCII but Android Studio shows Incompatible Encoding as
File 'Asciify.java' most likely isn't stored in the 'US-ASCII' encoding.
Why: BY_BYTES
Current encoding: 'UTF-8'
And the same is for windows-1252. I even tried to load these character sets forcefully But the android studio does nothing. Instead of reloading If I try to convert from one character set to another it corrupts the file. So my question is how can I fix this encoding error?
Thanks in advance.
I have non printable chars in eclipse ide window header, check screenshot. Locale ru_RU.UTF8. Webdings and windings fonts installed for ubuntu - dont known if java need some additional installation steps, also dont know is this chars belong to this fonts. Java version openjdk-8 on ubuntu17.10, default from repo. Also tried oracle-8-jre.
Non ascii chars work fine in editor.
Have read similar questions and google for it.
This not so important but interesting to fix it.
Not a bug. Just such header with \n in that plugin.
#Luis should add comment as answer.
I've been working for some time on my current project with Java (1.8.0_31) in IntelliJ IDEA (15.0.1 for Windows x64), where I use some text lines with special characters (e.g. "ó"). It has been working so far with no issue, but today it won't.
To put it short, I have a code line like this:
System.out.println("ó");
which has been outputting this (expected):
ó
Today, the output with the same source code is (unexpected):
ó
Code files are encoded in UTF-8 and the editor is setup accordingly. AFAIK, I've changed nothing.
I've created a brand new project to test this and it worked properly, so it may be something related specifically with my project.
Any idea about how to solve this?
I have a java file in Eclipse that is in UTF-8 and has some strings containing accents.
In the java file itself, the accent is written and saved as é .
In the xml that is generated using velocity the é becomes é
In the pdf that is generated using fop and and an xsl template, the output is displayed as é
So this is probably an encoding issue and everything should be in UTF-8. What's weird is that locally in my eclipse environment (windows) where I run the application, the whole process works and the correct accents é are displayed in the pdf.
However when the application is built with maven and deployed to a (unix environment) I see the problem described above.
Perhaps Eclipse is compiling the file with a different javac command line than Maven.
When you compile Java, you have to tell the compiler the encoding of the source files (if they contain non-ASCII characters and the default doesn't work).
javac -encoding utf8 MyCode.java
I think the way to fix this in Maven is to add this to your pom.xml file:
<project>
...
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
...
</project>
(I got that from a Maven FAQ about a slightly different issue.)
You could instead avoid the encoding issue entirely by using ugly Unicode escape sequences in your Java file. é would become \u00e9. Worse for humans, easier for the toasters. (As Perlis said, "In man-machine symbiosis, it is man who must adjust: The machines can't.")