Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / January 2006

Tip: Looking for answers? Try searching our database.

obtaining list of available encodings

Thread view: 
billposer@alum.mit.edu - 27 Oct 2005 22:57 GMT
I would like to obtain a list of the
available encodings at runtime. java.nio provides the
java.nio.charset.Charset.availableCharsets method for
doing this, but as far as I can tell there is no
comparable method for java.io, and using the java.nio
method won't help since java.io provides encodings
that are not available in java.nio. The only way I can
see to do this is the error-prone and ineffecient technique
of trying a long list of encodings and using the exceptions
to determine which ones are not available. Is there a simple way
to obtain a list of the encodings available in java.io
at runtime? Thanks.
Thomas Schodt - 28 Oct 2005 10:08 GMT
> ... java.nio provides the
> java.nio.charset.Charset.availableCharsets method for
> doing this, but as far as I can tell there is no
> comparable method for java.io, and

> using the java.nio
> method won't help since java.io provides encodings
> that are not available in java.nio.

I was under the impression that, under the hood,
java uses java.nio for all its charset needs.
billposer@alum.mit.edu - 28 Oct 2005 16:18 GMT
"I was under the impression that, under the hood,
java uses java.nio for all its charset needs. "

Indeed this is what some sources would lead one to believe, but it
isn't true. For instance, I successfully created an InputStreamReader
using the encoding CP918. If in the same program I evaluate
java.nio.charset.Charset.isSupported() for this encoding, it returns
false. This behavior is consistent with the information on this web
page:http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html,
according to which java.io and java.nio support different sets of
encodings. Roughly speaking, java.nio supports the various national and
international standards, while java.io adds various Microsoft and IBM
codepages.
Roedy Green - 28 Oct 2005 20:47 GMT
>Roughly speaking, java.nio supports the various national and
>international standards, while java.io adds various Microsoft and IBM
>codepages.

Is the code that implements them radically different?
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Thomas Schodt - 16 Jan 2006 19:35 GMT
> "I was under the impression that, under the hood,
> java uses java.nio for all its charset needs. "
[quoted text clipped - 5 lines]
> false. This behavior is consistent with the information on this web
> page:http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html

Well, no surprise, as Java 1.3 predates the java.nio package.

The 1.4.2 and 1.5 equivalent URLs exist and suggest that
the java.nio, java.io and java.lang APIs support the same encoding sets.
Roedy Green - 28 Oct 2005 14:07 GMT
>I would like to obtain a list of the
>available encodings at runtime. java.nio provides the
[quoted text clipped - 8 lines]
>to obtain a list of the encodings available in java.io
>at runtime? Thanks.

Have a look at my list. See http://mindprod.com/jgloss/encoding.html

I gleaned them by scanning class file and other cheating.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.