org.apache.tomcat.util.http
public class: LocaleToCharsetMap [javadoc |
source]
java.lang.Object
org.apache.tomcat.util.http.LocaleToCharsetMap
A mapping to determine the (somewhat arbitrarily) preferred charset for
a given locale. Supports all locales recognized in JDK 1.1.
This class was originally written by Jason Hunter [jhunter@acm.org]
as part of the book "Java Servlet Programming" (O'Reilly).
See
http://www.servlets.com/book for more information.
Used by Sun Microsystems with permission.
Method from org.apache.tomcat.util.http.LocaleToCharsetMap Summary: |
---|
getCharset |
Methods from java.lang.Object: |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method from org.apache.tomcat.util.http.LocaleToCharsetMap Detail: |
public static String getCharset(Locale loc) {
String charset;
// Try for an full name match (may include country)
charset = (String) map.get(loc.toString());
if (charset != null) return charset;
// If a full name didn't match, try just the language
charset = (String) map.get(loc.getLanguage());
return charset; // may be null
}
Gets the preferred charset for the given locale, or null if the locale
is not recognized. |