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

[EMAIL PROTECTED] changed:

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



------- Additional Comments From [EMAIL PROTECTED]  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:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to