aspose file tools*
The moose likes Servlets and the fly likes How to get Correct string( about charset ) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to get Correct string( about charset ) " Watch "How to get Correct string( about charset ) " New topic
Author

How to get Correct string( about charset )

zheng yu
Greenhorn

Joined: Apr 25, 2001
Posts: 28
TOMCAT3.2.1 + Oracle 8i + JDK1.2.2
My program get some records from database , and want to show it in browser correctly .
Interesting thing is : in DB , some fields has value like "0015","0036" ,but after i read its value from database ands print it to TOMCAT'slog , it beccomes "0x30303135"
"0x30303336", see , it seems something like ASCII code.
I know i should use :
new String ( somestring.getBytes( charsetFrom ) , charsetTo )
to get correct string that i want to display
the questions is i dont know what the charsetFrom & charsetTo will be .
another question :
Does charsetFrom has something to do with Oracle Server's encoding setting ? if it does , how can i know Oracle Server's
current encoding setting , and how can i change it ?
Thanx in advance
ZY
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040

Does charsetFrom has something to do with Oracle Server's encoding setting ? if it
does , how can i know Oracle Server's
current encoding setting , and how can i change it ?

Start sql then type this at the sql prompt:

SQL> select * from v$nls_parameters where parameter='NLS_CHARACTERSET';
PARAMETER
----------------------------------------------------------------
VALUE
----------------------------------------------------------------
NLS_CHARACTERSET
WE8ISO8859P1

This will indicate the Character set to you.
- satya

Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to get Correct string( about charset )