Netbeans 8.0.2 - cannot print utf-8 characters correctly

As the title says, I use Netbeans 8.0.2 on Windows 7. I saw a lot of different topics about it and tried different solutions, but it didn’t help anyone.

Thus, characters such as [š, ć, đ, ž, È, æ] are displayed as or squared depending on the font. Here is what I tried:

  • I set -J-Dfile.encoding=UTF-8 in ../etc/netbeans.conf
  • I checked the project settings and the encoding is set to utf-8

enter image description here

  • When I read the file, I use the following code:

    BufferedReader(new InputStreamReader(new FileInputStream(file), "UTF-8")); or using Charset.forName("UTF-8") or StandardCharsets.UTF_8 or Charset.forName("ISO8859-2") nothing helped.

Anyone have an idea what could be another problem?

+6
source share
3 answers

I found out that these characters [š, ć, đ, ž, È, æ] are types of Eastern European (Windows-1250).

So, the correct encoding type is "Windows-1250" .

+3
source

This is not a Netbeans problem per se; Netbeans FileAPI can open files in any encoding. When you do not know which encoding to use, you can use this plugin to dynamically change the encoding.

Update : you can find the plugin on the plugins official page as Encodding Support

+3
source

To read a text file encoded in UTF-8, use this code (Java 8):

 BufferedReader br = new BufferedReader(new InputStreamReader( new FileInputStream(file), StandardCharsets.UTF_8 )); 

To find the encoding of files, use one of the encoding detectors: What is the most accurate encoding detector?

To set the encoding for the program source code, use the following parameters:

  • Netbeans

     [project settings] / source / encoding = UTF-8 
  • Maven:

     <project> <properties> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> </properties> </project> 
+2
source

All Articles