tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 6569] - setLocale() doesn't set the Content-Type charset attribute
Date Wed, 20 Feb 2002 22:42:32 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6569>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6569

setLocale() doesn't set the Content-Type charset attribute

hans@gefionsoftware.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |



------- Additional Comments From hans@gefionsoftware.com  2002-02-20 22:42 -------
Thanks for the speedy fix. Unfortunately, it doesn't look like it's solving the
problem correctly. The new version of setLocale() looks like this:

    public void setLocale(Locale locale) {
        [...]
        this.locale = locale;
        if ((this.encoding == null) && (this.context != null)) {
            CharsetMapper mapper = context.getCharsetMapper();
            this.encoding = mapper.getCharset(locale);
            if ((contentType != null) && (contentType.indexOf(';') < 0)) {
                contentType = contentType + ";charset=" + encoding;
            }
        }
    }

This means the new Locale doesn't override an existing encoding, which it
should (to be consistent with how a charset in setContentType() is handled,
if nothing else). My suggestion is this:

    public void setLocale(Locale locale) {
        [...]
        this.locale = locale;
        if (this.context != null) {
            CharsetMapper mapper = context.getCharsetMapper();
            this.encoding = mapper.getCharset(locale);
            if (contentType != null) {
                if (contentType.indexOf(';') < 0)) {
                    contentType = contentType + ";charset=" + encoding;
                }
                else {
                    // Replace the previous charset
                    int i = contentType.indexOf(';');
                    contentType = contentType.substring(0, i) + 
                        ";charset=" + encoding;
                }
            }
        }
    }

--
To unsubscribe, e-mail:   <mailto:tomcat-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-dev-help@jakarta.apache.org>


Mime
View raw message