user11391059 :
I am trying to encode the Spanish language for internationalization and use the Java Properties class load method to populate it to pass it to frontend.
I have tried to encode it using UTF-8 but still the accent characters are not coming correctly.
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.Charset;
import java.util.Properties;
public class Message extends Properties {
public static void main(String[] args) throws IOException {
String spanish = "label=Sí";
Message messages = new Message();
messages.load(new ByteArrayInputStream(spanish.getBytes(Charset.forName("UTF-8"))));
System.out.println(messages.get("label"));
}
}
When i run the above code I am getting the text as "SÃ-". How can I retrieve the same text as "Sí"?
MS90 :
Try using ISO-8859-1 it gets expected result:
messages.load(new ByteArrayInputStream(spanish.getBytes(Charset.forName("ISO-8859-1"))));
More about ISO-8859-1 can be obtained from this link: https://en.wikipedia.org/wiki/ISO/IEC_8859-1