Methods Summary |
---|
public final java.nio.charset.Charset | charsetForName(java.lang.String charsetName)Constructs a charset for the given charset name
// get the canonical name
String icuCanonicalName = NativeConverter.getICUCanonicalName(charsetName);
// create the converter object and return it
if(icuCanonicalName==null || icuCanonicalName.length()==0){
// this would make the Charset API to throw
// unsupported encoding exception
return null;
}
// BEGIN android-added
try{
long cn = NativeConverter.openConverter(icuCanonicalName);
NativeConverter.closeConverter(cn);
}catch (RuntimeException re) {
// unsupported encoding. let the charset api throw an
// UnsupportedEncodingException
return null;
}
// END android-added
return getCharset(icuCanonicalName);
|
public final java.util.Iterator | charsets()Returns an iterator for the available charsets
String[] charsets = NativeConverter.getAvailable();
Iterator iter = new CharsetIterator(charsets);
return iter;
|
private final java.nio.charset.Charset | getCharset(java.lang.String icuCanonicalName)
String[] aliases = (String[])NativeConverter.getAliases(icuCanonicalName);
String canonicalName = NativeConverter.getJavaCanonicalName(icuCanonicalName);
return (new CharsetICU(canonicalName,icuCanonicalName, aliases));
|
public final void | putCharsets(java.util.Map map)Adds an entry to the given map whose key is the charset's
canonical name and whose value is the charset itself.
// Get the available converter canonical names and aliases
String[] charsets = NativeConverter.getAvailable();
for(int i=0; i<charsets.length;i++){
// store the charsets and aliases in a Map
if (!map.containsKey(charsets[i])){
map.put(charsets[i], charsetForName(charsets[i]));
}
}
|