Uploaded image for project: 'Sakai'
  1. Sakai
  2. SAK-11814

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

    XMLWordPrintable

    Details

    • Previous Issue Keys:
      RSV-23

      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.

        Gliffy Diagrams

          Zeplin

            Attachments

              Issue Links

                Activity

                  People

                  Assignee:
                  Unassigned Unassigned
                  Reporter:
                  sylvain.halde@crim.ca Sylvain Halde (Inactive)
                  Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                    Dates

                    Created:
                    Updated:
                    Resolved:

                      Git Integration