<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
    <title></title>
  </head>
  <body bgcolor="#ffffff" text="#000000">
    Hi Nicola,<br>
    <br>
    Something like this should work:<br>
    <br>
    <br>
    utf16 _ 'expo-test-IT-UTF16.xml' asFileEntry binaryContents.<br>
    possibleBOM _ utf16 copyFrom: 1 to: 2.<br>
    isLittleEndian _ true. "use your best guess"<br>
    possibleBOM = #[255 254] ifTrue: [<br>
        isLittleEndian _ true.<br>
        utf16 _ utf16 copyFrom: 3 to: utf16 size ].<br>
    possibleBOM = #[254 255] ifTrue: [<br>
        isLittleEndian _ false.<br>
        utf16 _ utf16 copyFrom: 3 to: utf16 size ].<br>
    String streamContents: [ :out |<br>
        index _ 1.<br>
        [index < utf16 size] whileTrue: [<br>
            codePoint _ utf16 unsignedShortAt: index bigEndian:
    isLittleEndian not.<br>
            out nextPut: (Character codePoint: codePoint).<br>
            index _ index + 2 ]].<br>
    <br>
    As you see, after messing a bit with the silly ByteOrderMark (BOM),
    all we do is grab 2 bytes and store them as a Character.<br>
    <br>
    Good luck with your project!<br>
    <br>
    Cheers,<br>
    <br>
    On 6/11/2022 5:02 AM, Nicola Mingotti via Cuis-dev wrote:
    <blockquote
cite="mid:CAG5qL5QEd6WJzWrNpiCsRoF-wHku=wtewk7i4Vvnh9xfqZbaVQ@mail.gmail.com"
      type="cite">
      <meta http-equiv="Context-Type" content="text/html; charset=UTF-8">
      <div>
        <div>Hi Jaun,</div>
        <div><br>
        </div>
        <div>I can share this data file, it is attached. <br>
        </div>
        <div>It is the output reading of a machine who does a NIR
          analysis on a corn sample.</div>
        <div>Once the machine GUI has been set to work in Italian. <br>
        </div>
        <div><br>
        </div>
        <div>bye</div>
        <div>Nicola<br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div><br>
        </div>
      </div>
      <br>
      <div>
        <div>On Sat, Jun 11, 2022 at 2:02 AM Juan Vuletich <<a
            moz-do-not-send="true" href="mailto:JuanVuletich@zoho.com">JuanVuletich@zoho.com</a>>
          wrote:<br>
        </div>
        <blockquote>
          <div> On 6/10/2022 8:25 PM, Nicola Mingotti via Cuis-dev
            wrote:
            <blockquote type="cite">
              <div>
                <div>Hi guys, <br>
                </div>
                <div><br>
                </div>
                <div>as title says, I am converting a script from Python
                  to Cuis.</div>
                <div>It reads an XML file and does stuff consequently.
                  Unfortunately the <br>
                </div>
                <div>XML is in UTF-16 (we are running in Windows).</div>
                <div><br>
                </div>
                <div>I am sure the file content is convertible to
                  Latin-1 since it is Italian</div>
                <div>text stuff. <br>
                </div>
                <div><br>
                </div>
                <div>Do you have any quick way to solve it from Cuis ?</div>
                <div><br>
                </div>
                <div>The XML part is working, already tested converting
                  UTF16 to Latin-1</div>
                <div>with an external editor. <br>
                </div>
                <div><br>
                </div>
                <div>bye</div>
                <div>Nicola</div>
              </div>
            </blockquote>
            <br>
            Hi Nicola,<br>
            <br>
            Can you send me (to the mail list or to <a
              moz-do-not-send="true" href="mailto:juan@jvuletich.org">juan@jvuletich.org</a>
            ) one of those files in a zip file? I'll show you how to do
            it, but I need an example. The zip file is to ensure that I
            get it exactly as you have it.<br>
            <br>
            Cheers,<br>
            <pre>-- 
Juan Vuletich
<a moz-do-not-send="true" href="http://www.cuis-smalltalk.org">www.cuis-smalltalk.org</a>
<a moz-do-not-send="true" href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a>
<a moz-do-not-send="true" href="https://github.com/jvuletich">https://github.com/jvuletich</a>
<a moz-do-not-send="true" href="https://www.linkedin.com/in/juan-vuletich-75611b3">https://www.linkedin.com/in/juan-vuletich-75611b3</a>
<a moz-do-not-send="true" href="https://independent.academia.edu/JuanVuletich">https://independent.academia.edu/JuanVuletich</a>
<a moz-do-not-send="true" href="https://www.researchgate.net/profile/Juan-Vuletich">https://www.researchgate.net/profile/Juan-Vuletich</a>
<a moz-do-not-send="true" href="https://patents.justia.com/inventor/juan-manuel-vuletich">https://patents.justia.com/inventor/juan-manuel-vuletich</a>
<a moz-do-not-send="true" href="https://twitter.com/JuanVuletich">https://twitter.com/JuanVuletich</a></pre>
          </div>
        </blockquote>
      </div>
    </blockquote>
    <br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Juan Vuletich
<a class="moz-txt-link-abbreviated" href="http://www.cuis-smalltalk.org">www.cuis-smalltalk.org</a>
<a class="moz-txt-link-freetext" href="https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev">https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev</a>
<a class="moz-txt-link-freetext" href="https://github.com/jvuletich">https://github.com/jvuletich</a>
<a class="moz-txt-link-freetext" href="https://www.linkedin.com/in/juan-vuletich-75611b3">https://www.linkedin.com/in/juan-vuletich-75611b3</a>
<a class="moz-txt-link-freetext" href="https://independent.academia.edu/JuanVuletich">https://independent.academia.edu/JuanVuletich</a>
<a class="moz-txt-link-freetext" href="https://www.researchgate.net/profile/Juan-Vuletich">https://www.researchgate.net/profile/Juan-Vuletich</a>
<a class="moz-txt-link-freetext" href="https://patents.justia.com/inventor/juan-manuel-vuletich">https://patents.justia.com/inventor/juan-manuel-vuletich</a>
<a class="moz-txt-link-freetext" href="https://twitter.com/JuanVuletich">https://twitter.com/JuanVuletich</a></pre>
  </body>
</html>