load properties files using UTF-8 instead of ISO 8859-1 (issue #1031)

This commit is contained in:
Karl Tauber
2025-09-06 12:45:40 +02:00
parent d388158de7
commit 6f63982054
7 changed files with 40 additions and 7 deletions

View File

@@ -20,6 +20,9 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Locale;
import java.util.Properties;
@@ -62,8 +65,8 @@ public class FlatPropertiesLaf
throws IOException
{
Properties properties = new Properties();
try( InputStream in2 = in ) {
properties.load( in2 );
try( Reader reader = new InputStreamReader( in, StandardCharsets.UTF_8 )) {
properties.load( reader );
}
return properties;
}

View File

@@ -25,12 +25,15 @@ import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.StreamTokenizer;
import java.io.StringReader;
import java.lang.reflect.Constructor;
import java.lang.reflect.Executable;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -112,6 +115,14 @@ class UIDefaultsLoader
Set<String> specialPrefixes = FlatLaf.getUIKeySpecialPrefixes();
return new Properties() {
@Override
public void load( InputStream in ) throws IOException {
// use UTF-8 to load properties file
try( Reader reader = new InputStreamReader( in, StandardCharsets.UTF_8 )) {
super.load( reader );
}
}
@Override
public synchronized Object put( Object k, Object value ) {
// process key prefixes (while loading properties files)