<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi,</p>
    <p><br>
    </p>
    <p>I am not sure whether this topic is of interest to anybody not on
      VA Smalltalk. Let me just explain my problem:</p>
    <p>VA Smalltalk is not (yet) natively UTF-8. So when you edit code
      in the Smalltalk Browser, it is encoded in the local codepage. In
      my case this is iso-8859-15. Seaside code and file library
      contents are served using a server adaptor. In VAST, this adaptor
      converts between UTF-8 for everything going to or coming from the
      Browser and the native code page. Not sure if this is the case on
      Pharo, Squeak or VW as well, but I guess so.</p>
    <p>So as long as you server the files from the Smalltalk image,
      special characters in, say javascript files, will be converted to
      UTF.8 when delivered to the Browser.</p>
    <p>The trouble starts when you use #deployFiles to have the files
      served by a web server (apache, nginx etc.). WAFileLibrary doesn't
      convert the files before writing them to the filesystem.</p>
    <p>I hacked GRVASTPlatform to handle this:</p>
    <pre>write: aStringOrByteArray toFile: aFileNameString inFolder: aFolderString
    "Writes @aStringOrByteArray to a file named @aFilenameString in
     the folder @aFolderString."
    
    |  fullFilePath stream <font color="#ff0000">str</font>|
    
    fullFilePath := CfsPath fromParts: (Array with: aFolderString with: aFileNameString).
    stream := fullFilePath newReadWriteStreamBinary: aStringOrByteArray isString not.
    
  <font color="#ff0000">  str := aStringOrByteArray isString ifTrue: [aStringOrByteArray convertToCodePage: 'UTF-8'] ifFalse: [aStringOrByteArray].
  </font>  [ stream nextPutAll: <font color="#ff0000">str</font> ]
        ensure: [ stream close ]
</pre>
    <p>The idea is that if teh contents of a method is not binary (like
      .png or .gif etc.), it most likely wants to be in UTF-8 on the
      file system.</p>
    <p>I am not sure, however, if the Grease layer is the right place
      for this. What if other users do not want the files converted to
      UTF-8. I am also not sure if it is okay to convert everything
      non-binary to UTF-8. Maybe there should be a way to tell a Library
      which codepage to convert to, or maybe it is desired to be able to
      decide for every file individually, or maybe even something else.<br>
    </p>
    <p>And, I am not even sure if this is even necessary on other
      platforms. That's why I post here first and ask for
      comments/discussion.<br>
    </p>
    <p><br>
    </p>
    <p>More on this topic: <a moz-do-not-send="true"
href="https://joachimtuchel.wordpress.com/2018/11/16/seaside-file-libraries-and-utf-8/">https://joachimtuchel.wordpress.com/2018/11/16/seaside-file-libraries-and-utf-8/</a><br>
    </p>
    <p><br>
    </p>
    <p>Joachim<br>
    </p>
    <p><br>
    </p>
  </body>
</html>