shym
shym

Reputation: 299

Java utf-8 encoding from url

I have a problem with some symbols in UTF-8 encoding. I am reading the index.html from http://wordki.pl to get the list of sets of words with their name.

it looks like this

<a href="THE LINK.html">THE NAME</a><span>(20)</span><img src="krecha.png">

and when THE NAME has "Ł" it doesent work and puts there "??" but the "??" is not a sign that i can change with replaceAll("str", "str") because my console just doesent show the char hidden behind it.

But when i view the source in chrome/firefox etc it shows "Ł". And all the other funny signs like "ó, ł, ą, ś" work fine in my program.

So I am asking if there is a way to change the "??" into "Ł" ? I tried encoding it byte by byte but then i lose all the other signs like "ó, ł, ą" etc.

EDIT: Ok i have the problem solved I needed to save my *.java file as UTF-8 : O

Upvotes: 0

Views: 859

Answers (1)

Siva Charan
Siva Charan

Reputation: 18064

You should set the page content-type as "UTF-8"

Do something like this:

request.getCharacterEncoding() = ISO-8859-1 
response.getCharacterEncoding() = UTF-8 
request.getParameter("query") = déjeuner

OR

  if(null == request.getCharacterEncoding())       
     request.setCharacterEncoding(encoding); 

  response.setContentType("text/html; charset=UTF-8");  
  response.setCharacterEncoding("UTF-8");

Refer this URL for more info:

How to get UTF-8 working in Java webapps?

<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> 

Upvotes: 1

Related Questions