Text documents created in Resources are encoded in jvm default encoding but always rendered in UTF-8

Description

When text document are created in Resources (not uploaded), character encoding is set to UTF-8 but bytes are read with getBytes().
Since getBytes() uses the character encoding default and not necessarily UTF-8, it fails to render special character when the resource is open in the browser.

Problem: (assuming your system default is not UTF-8 but "Windows-1252" for example)

In resources => Add => Create Text Document => Enter 'éèàçvf' => Save document
Click on the file to see it in your browser => special characters are not rendered correctly.

Fix:

In /content-tool/tool/src/java/org/sakaiproject/content/tool/ResourcesHelperAction.java#doContinue,
force UTF-8 encoding (and add alert.utf8encoding in types.properties) :

try {
pipe.setRevisedContent(content.getBytes(ResourcesAction.UTF_8_ENCODING));
} catch (UnsupportedEncodingException e) {
logger.warn("Unsupported Content Encoding");
addAlert(state, rb.getString("alert.utf8encoding"));
}

I attached the patch you can apply to fix ResourcesHelperAction.java (It also adds the key alert.utf8encoding in types.properties and fix the french and arabic misleading "Create Text Document" translation to "Nouveau document texte ANSI", etc.)

The patch would be apply to content, in the trunk.

Attachments

1
  • 04 Oct 2007, 03:31 PM

Activity

Show:

Filter Maintainer August 8, 2008 at 6:03 AM

2.5.0 QA has been completed. Unfortunately, there were not resources available to specifically test this issue. If you find this to still be a problem in the latest release (at this point 2.5.2), please reopen the JIRA and add the latest affects version.

Megan May February 6, 2008 at 9:16 AM

Sylvain, Any chance you or a colleague would be willing to verify that the fix resolved the problem you reported?

Megan May October 31, 2007 at 5:32 AM

Fixes included in 2.5.0.011 tag

Megan May October 29, 2007 at 2:05 PM

Merged into 2.5.x

Jim Eng October 29, 2007 at 1:37 PM

setting target version for 2.5.x

Fixed

Details

Priority

Affects versions

Fix versions

Assignee

Reporter

Environment

Trunk
Created October 4, 2007 at 3:31 PM
Updated October 23, 2008 at 6:28 AM
Resolved October 25, 2007 at 8:21 AM

Flag notifications