samuelhard
samuelhard

Reputation: 369

Retrieving non-English characters inserted values in MySQL database

I am working on inserting non-English characters in the database which is UTF-8 enabled. I am able to insert non-English characters in the database. When I insert the URL (it passes through response of JSP and because UTF8 encoding is set, it's converted to UTF8 format)

"1"

http://heenaparekh.com/category/%E0%AA%AF%E0%AA%BE%E0%AA%A4%E0%AB%8D%E0%AA%B0%E0%AA%BE%E0%AA%AA%E0%AB%8D%E0%AA%B0%E0%AA%B5%E0%AA%BE%E0%AA%B8/

it appears correctly in database table as

"2"

http://heenaparekh.com/category/યાતરાપરવાસ

But when I am trying to select the value with same string "1" which I used for inserting in the database (without passing through request and response of JSP) :

When the select statement is run with the link as same URL "1", it is converted to URL "2" by request of JSP.

When I want to select the rows with this URL, I am not able to extract as I am not able to convert URL "1" to URL "2" in my JSP application and I don't need to shift to different page so I have tried the following methods to convert it into URL "2" format:

I have tried converting my string to UTF-8 format but it's not helping. String is printed to be same. When I convert it using Entities class of Nutch to UTF8 format then also it is not fetching results, maybe as UTF8 conversion by response of JSP and Entities class are different.

Please help me how to bring both the URLs to same format so that I can extract it from the database.

Upvotes: 1

Views: 877

Answers (1)

artbristol
artbristol

Reputation: 32407

You need to URL-unencode rather than "UTF-unencode" the string. Internally, Java stores strings as UTF-16, but that doesn't matter for your purposes. Try the java.net.URLDecoder.decode(String, String) method.

Upvotes: 1

Related Questions