• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

Charset Conversion

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I am facing one problem with thai character encoding. I have some jsp pages for a mobile web application where I show some static thai text and some text is being fetched from Database tables. I am using Content-Type as "text/html; charset=utf-8".

The problem is the static thai text is appearing properly on mobile browsers but the text, fetched from database is not proper. its apearing like this "ÃËÑÊ»ÃШӵÑÇ" (This is the thai encoding I guess saved in database)
What could be the solution for this ?

If I use the static thai text in jsps as TIS-620 encoding and Content-Type as "text/html; charset=TIS-620". Than static and DB thai text both is coming properly. But only for some mobile browsers. May be these browsers support TIS-620 and others dont.

I have checked about java.nio.charset package, but could not find any working example over the net to convert TIS-620 text "ÃËÑÊ»ÃШӵÑÇ" to UTF-8.

is it possible to convert text from one charset encoding to other ?

Please help me. If I could not make you all understand the problem properly please let me know.

Nitin
 
Bartender
Posts: 11445
18
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Park Linkin wrote:



Welcome to the Ranch.
Please check your private messages for an important administrative matter.
 
Sheriff
Posts: 24632
56
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This article was written specifically to answer your question: Character Conversion from Browser to Database.
 
Nitin D Gaur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Paul,

thanks for your reply, but how to take data form browser to DB is not my problem.

my problem is how to convert data into utf-8 to be shown on browser.

If i use character encoding as windows-874 or tis-620 than its possible, but some mobile browsers dont support tis-620 and windows-874. Thats why I want to make data from DB, compatible to utf-8.

Nitin
 
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

my problem is how to convert data into utf-8 to be shown on browser.


Are you encountering an actual problem? Assuming that the DB charset is configured correctly, and you're using JDBC to access the DB, then what you get from the DB should be standard Java strings that you can just print to the JSP page (assuming that's correctly configured to show UTF-8).
 
Nitin D Gaur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The String which I am getting from DB is like this "¸¹Ò¤ÒáÃا෾" this is actually thai encoding in TIS-620 or windows-874..... I cant change DB data or conf.

what I need do is to convert this string to UTF-8, so that it could be shown on Browser.

I know that this can be done through java.nio.charset. But how I am not able to figure out.

Nitin.

 
Ulf Dittmer
Rancher
Posts: 43011
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you certain that it is stored correctly in the DB? A DB is configured for one -and only one- charset; which one is that in your case? You can't store data in various different charsets in a DB and expect it to get out correctly.
 
Nitin D Gaur
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dont be prejudice Man !!! That I am wrong.

if I use meta tag in my JSPs as.

<meta http-equiv="Content-Type" content="text/html; charset=tis-620" />
or
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />

I can manage to get proper results with the data from DB.

But when I change it to <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

I get junk characters. I have to use utf-8 content type only becasue tis-620 and windows-874 is not supported on all mobile devices.

 
No prison can hold Chairface Chippendale. And on a totally different topic ... my stuff:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!