Reputation: 5977
There are Norwegian characters in properties file. When i open in UTF-8 enabled Notepad++ it appears correctly:
Foreslåtte
But when i open same file in my Netbeans editor; it shows distorted characters like :
Foreslåtte
Netbeans Version in Use: 8.0.2.
Project Type: Maven Project
In Maven Proeject properties there is setting for UTF-8:
<properties>
<app.navn>posten</app.navn>
<jdk.version>1.8</jdk.version>
<wro4j.version>1.7.6</wro4j.version>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <--
<servlet.version>3.1.0</servlet.version>
</properties>
Could anyone help in finding what settings need to be done in Netbeans to get correct UTF-8 characters?
Upvotes: 5
Views: 8285
Reputation: 13261
Before Java 9, the encoding of a .properties file is ISO-8859-1, also known as Latin-1. All non-ASCII characters must be entered by using Unicode escape characters, e.g. \uHHHH where HHHH is a hexadecimal index of the character in the Unicode character set.
Source: https://en.m.wikipedia.org/wiki/.properties
Further read : https://www.google.com/search?q=java+properties+ascii
Upvotes: 1
Reputation: 6237
If you open netbeans folder, edit the netbeans.conf (It's inside the etc folder), you might need to open the editor with administrator rights first.
Add -J-Dfile.encoding=UTF-8
to the netbeans_default_options.
Restart netbeans, and it's now opening them correctly.
Upvotes: 2
Reputation: 5977
Right Click Properties File -> Properties -> Encoding -> Tick Use Project Encoding
Now open the file and matter resolved.
Note: My Project Encoding was already set to UTF-8. You can set i: Right Click on Project -> Properties -> Sources -> Select Encoding UTF-8
Upvotes: 9