You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by re...@apache.org on 2005/01/05 10:36:46 UTC
cvs commit: jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util CharsetMapperDefault.properties CharsetMapper.java
remm 2005/01/05 01:36:46
Modified: catalina/src/share/org/apache/catalina/util
CharsetMapperDefault.properties CharsetMapper.java
Log:
- Craig's version of this was quite different from the tainted version. I have rewritten the main "algorithm".
- The locale -> encoding list must be cleared, and will have to be reconstructed again from scratch
based on others contributions. Sevlet 2.4 webapps should be ok, as they are supposed to use the
locale to encoding declaration in web.xml.
Revision Changes Path
1.2 +0 -39 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/CharsetMapperDefault.properties
<<Binary file>>
1.6 +9 -22 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/CharsetMapper.java
Index: CharsetMapper.java
===================================================================
RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/util/CharsetMapper.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CharsetMapper.java 4 Jan 2005 22:14:42 -0000 1.5
+++ CharsetMapper.java 5 Jan 2005 09:36:46 -0000 1.6
@@ -31,7 +31,6 @@
* it loads, or by subclassing it (to change the algorithm) and then using
* your own version for a particular web application.
*
- * @author Jason Hunter
* @author Craig R. McClanahan
* @version $Date$ $Version$
*/
@@ -56,9 +55,7 @@
* Construct a new CharsetMapper using the default properties resource.
*/
public CharsetMapper() {
-
this(DEFAULT_RESOURCE);
-
}
@@ -71,7 +68,6 @@
* resource could not be loaded for any reason.
*/
public CharsetMapper(String name) {
-
try {
InputStream stream =
this.getClass().getResourceAsStream(name);
@@ -80,8 +76,6 @@
} catch (Throwable t) {
throw new IllegalArgumentException(t.toString());
}
-
-
}
@@ -95,8 +89,6 @@
private Properties map = new Properties();
-
-
// ------------------------------------------------------- Public Methods
@@ -108,20 +100,15 @@
* @param locale The locale for which to calculate a character set
*/
public String getCharset(Locale locale) {
-
- String charset = null;
-
- // First, try a full name match (language and country)
- charset = map.getProperty(locale.toString());
- if (charset != null)
- return (charset);
-
- // Second, try to match just the language
- charset = map.getProperty(locale.getLanguage());
+ // Match full language_country_variant first, then language only
+ String charset = map.getProperty(locale.toString());
+ if (charset == null) {
+ charset = map.getProperty(locale.getLanguage());
+ }
return (charset);
-
}
+
/**
* The deployment descriptor can have a
* locale-encoding-mapping-list element which describes the
@@ -131,8 +118,8 @@
* @param locale The locale for a character set
* @param charset The charset to be associated with the locale
*/
- public void addCharsetMappingFromDeploymentDescriptor(String locale,String charset) {
- map.put( locale, charset );
+ public void addCharsetMappingFromDeploymentDescriptor(String locale, String charset) {
+ map.put(locale, charset);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org