Index: src/main/java/com/xpn/xwiki/web/SkinAction.java
===================================================================
--- src/main/java/com/xpn/xwiki/web/SkinAction.java	(revision 10770)
+++ src/main/java/com/xpn/xwiki/web/SkinAction.java	(working copy)
@@ -21,8 +21,9 @@
 package com.xpn.xwiki.web;
 
 import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
 import java.util.Date;
-import java.util.Arrays;
 
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
@@ -196,9 +197,11 @@
             byte[] data;
             data = context.getWiki().getResourceContentAsBytes(path);
             if (data != null && data.length > 0) {
+                String xwikiEncoding = null;
                 String mimetype = context.getEngineContext().getMimeType(filename.toLowerCase());
                 Date modified = null;
                 if (isCssMimeType(mimetype) || isJavascriptMimeType(mimetype)) {
+                    xwikiEncoding = context.getWiki().getEncoding();
                     byte[] newdata = context.getWiki().parseContent(new String(data), context).getBytes();
                     // If the content contained velocity code, then it should not be cached
                     if (Arrays.equals(newdata, data)) {
@@ -212,7 +215,7 @@
                 else {
                     modified = context.getWiki().getResourceLastModificationDate(path);
                 }
-                setupHeaders(response, mimetype, modified, data.length);
+                setupHeaders(response, mimetype, xwikiEncoding, modified, data.length);
                 try {
                     response.getOutputStream().write(data);
                 } catch (IOException e) {
@@ -240,7 +243,7 @@
      * @throws IOException If the response cannot be sent.
      */
     public boolean renderFileFromObjectField(String filename, XWikiDocument doc,
-        XWikiContext context) throws IOException
+        XWikiContext context) throws IOException, XWikiException
     {
         LOG.debug("... as object property");
         BaseObject object = doc.getObject("XWiki.XWikiSkins");
@@ -252,11 +255,21 @@
         if (!StringUtils.isBlank(content)) {
             XWiki xwiki = context.getWiki();
             XWikiResponse response = context.getResponse();
+            String xwikiEncoding = xwiki.getEncoding();
             String mimetype = xwiki.getEngineContext().getMimeType(filename.toLowerCase());
             if (isCssMimeType(mimetype) || isJavascriptMimeType(mimetype)) {
                 content = context.getWiki().parseContent(content, context);
             }
-            setupHeaders(response, mimetype, doc.getDate(), content.length());
+            int len;
+            try {
+                len = content.getBytes(context.getWiki().getEncoding()).length;
+            } catch (UnsupportedEncodingException e) {
+                throw new XWikiException(XWikiException.MODULE_XWIKI_APP,
+                    XWikiException.ERROR_XWIKI_APP_SEND_RESPONSE_EXCEPTION,
+                    "Exception while sending response",
+                    e);
+            }
+            setupHeaders(response, mimetype, xwikiEncoding, doc.getDate(), len);
             response.getWriter().write(content);
             return true;
         } else {
@@ -283,12 +296,14 @@
         if (attachment != null) {
             XWiki xwiki = context.getWiki();
             XWikiResponse response = context.getResponse();
+            String xwikiEncoding = null;
             byte[] data = attachment.getContent(context);
             String mimetype = xwiki.getEngineContext().getMimeType(filename.toLowerCase());
             if (isCssMimeType(mimetype) || isJavascriptMimeType(mimetype)) {
+                xwikiEncoding = xwiki.getEncoding();
                 data = context.getWiki().parseContent(new String(data), context).getBytes();
             }
-            setupHeaders(response, mimetype, attachment.getDate(), data.length);
+            setupHeaders(response, mimetype, xwikiEncoding, attachment.getDate(), data.length);
             response.getOutputStream().write(data);
             return true;
         } else {
@@ -335,11 +350,15 @@
      *            header.
      * @param length The length of the content (in bytes). Used in the "Content-Length" header.
      */
-    protected void setupHeaders(XWikiResponse response, String mimetype, Date lastChanged,
+    protected void setupHeaders(XWikiResponse response, String mimetype, String encoding, Date lastChanged,
         int length)
     {
         if (!StringUtils.isBlank(mimetype)) {
-            response.setContentType(mimetype);
+            if (encoding != null) {
+                response.setContentType(mimetype + ";charset=" + encoding);
+            } else {
+                response.setContentType(mimetype);
+            }
         } else {
             response.setContentType("application/octet-stream");
         }
