[opencms-dev] The code i modified for Simplified Chinese display

??? shiys at langhua.cn
Sun Apr 25 17:30:00 CEST 2004


1. Change Encoder.java:
add the following:
    /**
     * Changes the encoding of a string in Cms resources.
     * added by Shi Yesen, email: shiys at langhua.cn
     */
    public static String changeEncoding(String input, String oldEncoding, String newEncoding) {
        if ((oldEncoding == null) || (newEncoding == null)) return input;
        if ((oldEncoding.trim()).equalsIgnoreCase(newEncoding.trim())) return input;
        String result = input;
        try {
            result = new String(input.getBytes(oldEncoding), newEncoding);
        } catch (UnsupportedEncodingException e) {
            // return value will be input value
        }
        return result;
    }
    
2. Change CmsMessages.java:
original: return m_messages.getString(keyName);
new:       return Encoder.changeEncoding(m_bundle.getString(keyName), "ISO-8859-1", A_OpenCms.getDefaultEncoding());
A_OpenCms.getDefaultEncoding()="GB2312". The m_bundle's string is encoding in ISO-8859-1 by default, it should be changed into GB2312.

3.Import Simplified Chinsese Language module

4. Set GB2312 as the default encoding in opencms.properties.

5. Set MySQL's default-character-set=gb2312.

I guess these changes also work for Japanese and Korean. 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: org.opencms.locales.cn_1.0.zip
Type: application/octet-stream
Size: 14929 bytes
Desc: not available
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20040425/30895202/attachment.obj>


More information about the opencms-dev mailing list