I am writing a web app where for creating news. I want to use letters which do not belong to English alphabet, such as šđčćž. These letters can be UTF8 encoded but it does not work in my app.
I have two text fields in which I enter data. One of them is for news headline and the other one is for news content. Both of these fields are required. After saving the news and checking database I get some weird characters instead of the entered ones.
I have already tried adding in the JSF page and it did not help
<?xml version="1.0" encoding="UTF-8" ?>
I have also tried the following in my news managed Bean when setting the news headline and content:
public void setHeadline(String headline){
this.headline = new String(headline.getBytes("iso-8859-1"),"utf-8")
}
public void setContent(String content{
this.content = new String(content.getBytes("iso-8859-1"),"utf-8")
}
This helped when I enter both the headline and content and save them. But, if a user would forget to enter data into any one of these fields, the data does not get stored to the database (which is okay since the fields are required), but the field in which the data did get entered transforms the letters šđčćž into weird characters.