<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic About file encoding and freemarker (Cp1252 vs UTF-8) in Alfresco Archive</title>
    <link>https://connect.hyland.com/t5/alfresco-archive/about-file-encoding-and-freemarker-cp1252-vs-utf-8/m-p/55054#M33007</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I run into some troubles with the encoding when using email templates through the MailActionExecuter class even that everything (server, mailserver, … ) was set to UTF-8 !&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;My content also was written with UTF-8 encoding&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;After going down deeper and deeper the source, i get the following solution:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On creation of the &lt;/SPAN&gt;&lt;EM&gt;freemarker.template.Configuration&lt;/EM&gt;&lt;SPAN&gt; class, the system property "file.encoding" from the JVM is loaded as default encoding…&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;On JVM installation, sometimes, 'Cp1252' encoding is set automatically (for well-known but obscure reason…)&amp;nbsp; :? &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;To avoid this problem, add the following option to your JVM options:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;-Dfile.encoding=UTF-8&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;JM&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 24 Oct 2006 07:52:12 GMT</pubDate>
    <dc:creator>jmliege</dc:creator>
    <dc:date>2006-10-24T07:52:12Z</dc:date>
    <item>
      <title>About file encoding and freemarker (Cp1252 vs UTF-8)</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/about-file-encoding-and-freemarker-cp1252-vs-utf-8/m-p/55054#M33007</link>
      <description>Hi,I run into some troubles with the encoding when using email templates through the MailActionExecuter class even that everything (server, mailserver, … ) was set to UTF-8 !My content also was written with UTF-8 encodingAfter going down deeper and deeper the source, i get the following solution&lt;IMG id="smileysurprised" class="emoticon emoticon-smileysurprised" src="https://migration33.stage.lithium.com/i/smilies/16x16_smiley-surprised.png" alt="Smiley Surprised" title="Smiley Surprised" /&gt;n</description>
      <pubDate>Tue, 24 Oct 2006 07:52:12 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/about-file-encoding-and-freemarker-cp1252-vs-utf-8/m-p/55054#M33007</guid>
      <dc:creator>jmliege</dc:creator>
      <dc:date>2006-10-24T07:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: About file encoding and freemarker (Cp1252 vs UTF-8)</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/about-file-encoding-and-freemarker-cp1252-vs-utf-8/m-p/55055#M33008</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Thanks for the tip, to me that looks like something that should be configurable as part of the FreeMarker setup configuration in Alfresco.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The FreeMarker engine doesn't know that it's processing templates for Emails, HTML, XML or whatever - so I don't think we should push the email encoding value down into the config. Iinstead I think it should be a separate config property that is part of the Alfresco FreeMarker Template processor bean config.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I have raised an issue for this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;A href="http://issues.alfresco.com/browse/AR-1041" rel="nofollow noopener noreferrer"&gt;http://issues.alfresco.com/browse/AR-1041&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Thanks again,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Kevin&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 24 Oct 2006 08:36:50 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/about-file-encoding-and-freemarker-cp1252-vs-utf-8/m-p/55055#M33008</guid>
      <dc:creator>kevinr</dc:creator>
      <dc:date>2006-10-24T08:36:50Z</dc:date>
    </item>
    <item>
      <title>Re: About file encoding and freemarker (Cp1252 vs UTF-8)</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/about-file-encoding-and-freemarker-cp1252-vs-utf-8/m-p/55056#M33009</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I am using Alfresco 1.4.0 Enterprise and i run into the same encoding problem. I took a look at the template-services-context.xml and find a commented "defaultEncoding" parameter.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I tried to uncomment it, but it did not solve my problems. I also tried to to change the value of this parameter with no visible result.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Did I miss something?&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;PS : tried on Windows XP and Debian/Sarge&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 06 Dec 2006 10:55:01 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/about-file-encoding-and-freemarker-cp1252-vs-utf-8/m-p/55056#M33009</guid>
      <dc:creator>unknown-user</dc:creator>
      <dc:date>2006-12-06T10:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: About file encoding and freemarker (Cp1252 vs UTF-8)</title>
      <link>https://connect.hyland.com/t5/alfresco-archive/about-file-encoding-and-freemarker-cp1252-vs-utf-8/m-p/55057#M33010</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I believe this also impacts webscripts when they call for content with remote.call / get / post etc&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Say you have an Alfresco / Share setup and are returning XML containing UTF-8 from Alfresco via a webscript and a share webscript consuming that Alfresco repository service.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I've found on my mac that if I simply call the script with my browser it works fine (encoding handled properly etc.)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;If I call the same service with a webscript, set the response to a freemarker template and in the template simply print the variable I see issues.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;If I look at Java's default character set I see it is set to MacRoman.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;What we determined with this is that while the Webscript connector seems to be assuming the encoding is the default encoding, the bytes are actually UTF-8.&amp;nbsp; This means that as far as java is concerned, any consumer down the line who asks for UTF-8 representation of this string needs an conversion. The bytes (which are actually already UTF-8 bytes) are mistakenly "converted."&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;There are two ways to prove this:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;1.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If I set the java default encoding on the JVM&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; export JAVA_OPTS='BLAH BLAH -Dfile.encoding=UTF-8' &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I get the proper output on the client (share based) webscript&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;2. doing what would otherwise be non-sensical:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (without the default encoding explicitly set with -D…)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var callResponse = remote.call("/myXml-In-UTF-8");&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; model.foo = new java.lang.String(callResponse.response.getBytes("macRoman"), "UTF-8");&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; printing this in the FTL:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {foo}&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; gives you the proper response even though the code above is "crazy talk." &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BLOCKQUOTE class="jive-quote"&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I run into some troubles with the encoding when using email templates through the MailActionExecuter class even that everything (server, mailserver, … ) was set to UTF-8 !&lt;BR /&gt;My content also was written with UTF-8 encoding&lt;BR /&gt;&lt;BR /&gt;After going down deeper and deeper the source, i get the following solution:&lt;BR /&gt;&lt;BR /&gt;On creation of the &lt;EM&gt;freemarker.template.Configuration&lt;/EM&gt; class, the system property "file.encoding" from the JVM is loaded as default encoding…&lt;BR /&gt;&lt;BR /&gt;On JVM installation, sometimes, 'Cp1252' encoding is set automatically (for well-known but obscure reason…)&amp;nbsp; :? &lt;BR /&gt;&lt;BR /&gt;To avoid this problem, add the following option to your JVM options:&lt;BR /&gt;-Dfile.encoding=UTF-8&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;JM&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 Jun 2010 20:55:45 GMT</pubDate>
      <guid>https://connect.hyland.com/t5/alfresco-archive/about-file-encoding-and-freemarker-cp1252-vs-utf-8/m-p/55057#M33010</guid>
      <dc:creator>rdanner</dc:creator>
      <dc:date>2010-06-29T20:55:45Z</dc:date>
    </item>
  </channel>
</rss>

