Kapparino
Kapparino

Reputation: 988

netbeans 8.0.2 - can not print utf-8 characters correctly

As title says, I'm using Netbeans 8.0.2, on Windows 7 OS. I saw many different topics about this and tried different solutions, but none really helped.

So characters like [š, ć, đ, ž, È, æ] are displayed as � or squared, depending on the font. Here is what I've tried:

enter image description here

Any one has idea what other problem could be ?

Upvotes: 6

Views: 4154

Answers (3)

Ruslan López
Ruslan López

Reputation: 4477

That's not a Netbeans issue per se, The netbeans FileAPI can open files in any encoding. When you don't know what encoding to use you can use this plugin to change the encoding dinamically.

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

Upvotes: 3

kinjelom
kinjelom

Reputation: 6460

To read text file with UTF-8 encoding use this code (Java 8):

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

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

To set encoding for your program source code use this settings:

  • Netbeans

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

    <project>
      <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      </properties>
    </project>
    

Upvotes: 2

Kapparino
Kapparino

Reputation: 988

I have found out that this characters [š, ć, đ, ž, È, æ] are type Eastern European (Windows-1250).

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

Upvotes: 3

Related Questions