<?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 Output of UTF-8 characters in Intel® Fortran Compiler</title>
    <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609008#M172677</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem with writing of UTF-8 encoded characters to disk. I need this for my language unfortunately has some non-ascii characters and As I user German data sourdes text items will have these 'Umlauts'. Here is my simple code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;!
!   Test Unicode UTF-8 input from file, handling and output to file
!
program UnicodeTest
implicit none

character*16 cString1, cString2
integer iRslt

open (unit = 10, fIle = 'Unicode_In.csv', encoding = 'UTF-8', iostat = iRslt)
read (10,'(a16)') cString1
cString2 = 'aäoöuüAÄOÖUÜszß'
open(unit = 11, file = 'Unicode_Out.csv', encoding = 'UTF-8')
write (11, '(a16)') cString1
write (11, '(a16)') cString2

stop
end&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unicode_In.csv contains the same string as cString2 defined in line #12:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;aäoöuüAÄOÖUÜszß&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the output-file is then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;aäoöuüAÄOÖU
a䯶uüAď֕ܳzߠ&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So while my input from file is processed properly (though censored), strings that are defined within the program seem not get encoded for output properly. And because my output will contain some explanatory text, I would like to have&amp;nbsp; it properly encoded as well.&lt;/P&gt;&lt;P&gt;Any Idea anybody?&lt;/P&gt;</description>
    <pubDate>Sat, 22 Jun 2024 17:19:12 GMT</pubDate>
    <dc:creator>Paul_Felz</dc:creator>
    <dc:date>2024-06-22T17:19:12Z</dc:date>
    <item>
      <title>Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609008#M172677</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a problem with writing of UTF-8 encoded characters to disk. I need this for my language unfortunately has some non-ascii characters and As I user German data sourdes text items will have these 'Umlauts'. Here is my simple code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;!
!   Test Unicode UTF-8 input from file, handling and output to file
!
program UnicodeTest
implicit none

character*16 cString1, cString2
integer iRslt

open (unit = 10, fIle = 'Unicode_In.csv', encoding = 'UTF-8', iostat = iRslt)
read (10,'(a16)') cString1
cString2 = 'aäoöuüAÄOÖUÜszß'
open(unit = 11, file = 'Unicode_Out.csv', encoding = 'UTF-8')
write (11, '(a16)') cString1
write (11, '(a16)') cString2

stop
end&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unicode_In.csv contains the same string as cString2 defined in line #12:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;aäoöuüAÄOÖUÜszß&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the output-file is then&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;aäoöuüAÄOÖU
a䯶uüAď֕ܳzߠ&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So while my input from file is processed properly (though censored), strings that are defined within the program seem not get encoded for output properly. And because my output will contain some explanatory text, I would like to have&amp;nbsp; it properly encoded as well.&lt;/P&gt;&lt;P&gt;Any Idea anybody?&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2024 17:19:12 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609008#M172677</guid>
      <dc:creator>Paul_Felz</dc:creator>
      <dc:date>2024-06-22T17:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609014#M172678</link>
      <description>&lt;P&gt;Not sure if this has anything to do with the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;UTF8 files generally have the &lt;A href="https://en.wikipedia.org/wiki/Byte_order_mark#UTF-8" target="_self"&gt;UTF8 BOM&lt;/A&gt; (Byte Order Marking) as the first 3 bytes of the file.&lt;/P&gt;&lt;P&gt;See it is present (or required) to be in the file created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jim Dempsey&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2024 18:32:51 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609014#M172678</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2024-06-22T18:32:51Z</dc:date>
    </item>
    <item>
      <title>Re: Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609024#M172679</link>
      <description>&lt;P&gt;You might read this.....&amp;nbsp;&lt;A href="https://fortran-lang.discourse.group/t/using-unicode-characters-in-fortran/2764" target="_blank"&gt;https://fortran-lang.discourse.group/t/using-unicode-characters-in-fortran/2764&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Jun 2024 22:51:57 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609024#M172679</guid>
      <dc:creator>andrew_4619</dc:creator>
      <dc:date>2024-06-22T22:51:57Z</dc:date>
    </item>
    <item>
      <title>Re: Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609066#M172686</link>
      <description>&lt;P&gt;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/270211"&gt;@Paul_Felz&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Considering the link&amp;nbsp;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/66560"&gt;@andrew_4619&lt;/a&gt;&amp;nbsp;posted, your best bet would be to open the file as Stream.&lt;/P&gt;&lt;P&gt;Add the UTF8 BOM marker on first write&lt;/P&gt;&lt;P&gt;Check/skip the UTF8 BOM marker on first read&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will have to experiment with keeping/removing the encoding='UTF-8'&lt;/P&gt;&lt;P&gt;AND check to see if you have any nA format descriptors to confirm if/if not the n represents multi-byte characters as 1 byte or 2,3,4 bytes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jim Dempsey&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2024 12:48:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609066#M172686</guid>
      <dc:creator>jimdempseyatthecove</dc:creator>
      <dc:date>2024-06-23T12:48:45Z</dc:date>
    </item>
    <item>
      <title>Re: Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609100#M172689</link>
      <description>&lt;P&gt;Thanks to all of you.&lt;/P&gt;&lt;P&gt;The link Andrew gave was quite informative. But unfortunately this did not solve my problem, because my issue was not covered: Output of a non-ascii string generated within the program.&lt;/P&gt;&lt;P&gt;I tried with BOM markers but this did not solve the problem either.&lt;/P&gt;&lt;P&gt;Here is the code I tried in the end:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;program UnicodeTest
implicit none

character*100 cString1, cString2
integer iRslt
character*3 cBOM

cBOM(1:1) = char(239)
cBOM(2:2) = char(187)
cBOM(3:3) = char(191)

open (unit = 10, fIle = 'Unicode_In.csv', encoding = 'UTF-8', iostat = iRslt)
read (10,'(a20)') cString1
cString2 = 'aäoöuüAÄOÖUÜszß'

open(unit = 11, file = 'Unicode_Out.csv', encoding = 'UTF-8')

write (11, *) cBOM, trim(cString1)
write (11, *) cBOM, trim(cString2)

stop
end&lt;/LI-CODE&gt;&lt;P&gt;And regardless if I put this marker at the beginning of the output-lines or not, the strings remained the same as before.&lt;/P&gt;&lt;P&gt;I checked the input file - which was encoded as UTF-8 by using Libre-Office Calc - with a Hex-Editor and there was no such marker present. This is what Unicode_out.csv looks like&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unicode_Out_HEX.png" style="width: 644px;"&gt;&lt;img src="https://community.intel.com/t5/image/serverpage/image-id/56227i33C274EC23AAD993/image-size/large/is-moderation-mode/true?v=v2&amp;amp;px=999&amp;amp;whitelist-exif-data=Orientation%2CResolution%2COriginalDefaultFinalSize%2CCopyright" role="button" title="Unicode_Out_HEX.png" alt="Unicode_Out_HEX.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;What puzzles me greatly is the fact that in the HEX-editor the first string is not legible but the second is - while in the output it is the nother way round.&lt;/P&gt;&lt;P&gt;What did I miss?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Jun 2024 17:35:18 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609100#M172689</guid>
      <dc:creator>Paul_Felz</dc:creator>
      <dc:date>2024-06-23T17:35:18Z</dc:date>
    </item>
    <item>
      <title>Re: Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609123#M172691</link>
      <description>&lt;P&gt;Edited delete as not correct.&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 05:42:23 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609123#M172691</guid>
      <dc:creator>MWind2</dc:creator>
      <dc:date>2024-06-24T05:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609684#M172716</link>
      <description>&lt;P&gt;cstring2 is written out as bytes, cstring1 input is UTF-8.&lt;/P&gt;&lt;P&gt;Some code used to make UTF-16LE included; Windows c dll and Fortran exe.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 16:11:37 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609684#M172716</guid>
      <dc:creator>MWind2</dc:creator>
      <dc:date>2024-06-25T16:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609736#M172725</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://community.intel.com/t5/user/viewprofilepage/user-id/648"&gt;@MWind2&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;cstring2 is written out as bytes, cstring1 input is UTF-8.&lt;/P&gt;
&lt;P&gt;Some code used to make UTF-16LE included; Windows c dll and Fortran exe.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Is it possible to include all in one zip file?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 20:35:15 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1609736#M172725</guid>
      <dc:creator>Devorah_H_Intel</dc:creator>
      <dc:date>2024-06-25T20:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1610016#M172736</link>
      <description>&lt;P&gt;Thanks MWind2&lt;/P&gt;&lt;P&gt;Because it is a very limited number of characters only that give me the headaches, I added a few lines to my input-routine, that replaces two-byte entries for the special characters to the single internal one. On output I will do just vice versa (not yet completed). Here is my code, that I use to parse my semicolon-seperated input lines. :&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;character*1024 Function cParser(cLine)
    implicit none
    character*1024 cLine
    character*2, dimension(7) :: cOld
    character*1, dimension(7) :: cNew
    integer j
    integer iPos
!** Characters to be replaced
    cOld(1) = char(195)//char(164)      ! ä
    cOld(2) = char(195)//char(182)      ! ö
    cOld(3) = char(195)//char(188)      ! ü
    cOld(4) = char(195)//char(132)      ! Ä
    cOld(5) = char(195)//char(150)      ! Ö
    cOld(6) = char(195)//char(156)      ! Ü
    cOld(7) = char(195)//char(159)      ! ß
!*** by these literals
    cNew(1) = char(228)
    cNew(2) = char(246)
    cNew(3) = char(252)
    cNew(4) = char(196)
    cNew(5) = char(214)
    cNew(6) = char(220)
    cNew(7) = char(223)
 
!*** find next ;
    iPos = index (cLine,';')
!*** if there is none - return rest of line and scratch it.
    if (iPos .eq. 0) then
        cParser = trim(cLine)
        cLine = ''
        return
!*** if it is the first sign, return empty string and cut off ;
    else if (iPos .eq. 1) then
        cParser = ''
        cLine = cLine (iPos + 1 :)
        return
!*** If it is anywhere in the record, process the string up to the ;
    else
        cParser = adjustl (cLine (1 : iPos - 1))
        !*** discard the read part from the input record
        cLine = cLine (iPos + 1 :)
        !*** Replace special characters until there are no more
        do j = 1, 7
            do
                iPos = index (cParser, cOld(j))
                if (iPos .eq. 0) exit
                cParser = cParser (: iPos - 1) // cNew(j) // cParser (iPos + 2 :)
            enddo
        enddo               
    endif
    return
end&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 15:57:45 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1610016#M172736</guid>
      <dc:creator>Paul_Felz</dc:creator>
      <dc:date>2024-06-26T15:57:45Z</dc:date>
    </item>
    <item>
      <title>Re: Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1610354#M172768</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;First : The BOM must be written only once at the beginning of the file. It indicates that the content of the file must be interpreted as UTF8. The BOM is not mandatory, some editors like Notepad++ allow automatic encoding detection and selection of the desired character encoding.&lt;/P&gt;&lt;P&gt;Second : By using * format specifier, I think that a space is inserted at the beginning of each line and so the BOM cannot be interpreted.&lt;/P&gt;&lt;P&gt;Third : I think that your character constant is encoded as your source file. So, if true, your source file must be encoded in UTF8.&lt;/P&gt;&lt;P&gt;Fourth : An UTF8 string&amp;nbsp; is longer than the number of displayed characters. So you must oversize your character variables from 16 to 32 minimum to avoid truncation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 12:27:19 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1610354#M172768</guid>
      <dc:creator>GVautier</dc:creator>
      <dc:date>2024-06-27T12:27:19Z</dc:date>
    </item>
    <item>
      <title>Re: Output of UTF-8 characters</title>
      <link>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1610372#M172771</link>
      <description>&lt;P&gt;Sorry, OK.&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jun 2024 13:51:24 GMT</pubDate>
      <guid>https://community.intel.com/t5/Intel-Fortran-Compiler/Output-of-UTF-8-characters/m-p/1610372#M172771</guid>
      <dc:creator>MWind2</dc:creator>
      <dc:date>2024-06-27T13:51:24Z</dc:date>
    </item>
  </channel>
</rss>

