Extension SDK 10.1.2

oracle.ide.util
Class Encodings

java.lang.Object
  extended byoracle.ide.util.Encodings

public final class Encodings
extends java.lang.Object

Utility class for dealing with character encodings. The determination of what encodings are available is based on the information supplied by Charset. Mapping from an alias to a canonical (IANA) name is provided.


Field Summary
static java.lang.String UTF8_ENCODING
          The name of the 'UTF-8' encoding.
 
Method Summary
static java.lang.String convertJdk2IanaEncoding(java.lang.String jdkEncoding)
          Converts the specified JDK encoding to an IANA encoding.
static java.lang.String getDefaultEncoding()
          Returns the default character encoding being used by the Java implementation.
static java.lang.String getDefaultIanaEncoding()
          Returns the default character encoding name being used by the Java implementation as a suitable IANA name.
static java.lang.String[] getEncodings()
          Returns a string array of encodings that are supported by the Java implementation.
static boolean isDefaultCp1252()
          Certain optimizations can be performed when the running JDK's default character encoding is "Cp1252".
static boolean isSupported(java.lang.String encoding)
          Returns true if the specified encoding is supported by the Java implementation.
static void loadEncodings(javax.swing.JComboBox comboBox, boolean addDefaultItem, java.lang.String selectedEncoding)
          The specified JComboBox is populated with all of the available character encodings in the currently running JDK.
static void setEncodingsFile(java.io.File encodingsFile)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UTF8_ENCODING

public static final java.lang.String UTF8_ENCODING
The name of the 'UTF-8' encoding.

See Also:
Constant Field Values
Method Detail

setEncodingsFile

public static void setEncodingsFile(java.io.File encodingsFile)

isSupported

public static boolean isSupported(java.lang.String encoding)
Returns true if the specified encoding is supported by the Java implementation. Returns false if the encoding is not supported.


getDefaultEncoding

public static java.lang.String getDefaultEncoding()
Returns the default character encoding being used by the Java implementation. This method will only determine the default encoding once. After that the result is cached.


getDefaultIanaEncoding

public static java.lang.String getDefaultIanaEncoding()
Returns the default character encoding name being used by the Java implementation as a suitable IANA name. Sun's JDK uses many non-standard encoding names, and this can lead to problems with parsing XML files when an XML file has a declared encoding that is not recognized on a different platform or locale.

Use this method to get an encoding name for the current platform and locale that is most likely to be recognized by another XML parser.


convertJdk2IanaEncoding

public static java.lang.String convertJdk2IanaEncoding(java.lang.String jdkEncoding)
Converts the specified JDK encoding to an IANA encoding.


getEncodings

public static java.lang.String[] getEncodings()
Returns a string array of encodings that are supported by the Java implementation. This method will only search for encodings once. After that the result is cached.


isDefaultCp1252

public static boolean isDefaultCp1252()
Certain optimizations can be performed when the running JDK's default character encoding is "Cp1252". This method provides a standard way of detecting that the encoding is Cp1252.


loadEncodings

public static void loadEncodings(javax.swing.JComboBox comboBox,
                                 boolean addDefaultItem,
                                 java.lang.String selectedEncoding)
The specified JComboBox is populated with all of the available character encodings in the currently running JDK. The determination of available encodings is run on a separate thread, and then the combo box's model is changed on the Swing event thread. The very first item in the combobox is "Default", which the application should interpret to mean that no encoding is specified and therefore a default encoding should be used that is appropriate for the current locale.

The selectedEncoding parameter is used to specify which encoding in the combobox should initially come up as selectd. This can be null, which means that the "Default" item will be selected.


Extension SDK

 

Copyright © 1997, 2004, Oracle. All rights reserved.