Does the OPEN function in GNU Fortran support Unicode file names ?
And Unicode file paths ?
On Wednesday, July 14, 2021 at 7:24:44 PM UTC-7, Lynn McGuire wrote:
Does the OPEN function in GNU Fortran support Unicode file names ?
And Unicode file paths ?Using trial and no error, it seems that 4.1.2 and 6.3.0 can do it.
I presume you have to use it on a file system that supports them.
open(unit=1,file='🦛🐦🐑🐑')
write(1,*) '🦛🐦🐑🐑'
end
On Wednesday, July 14, 2021 at 7:24:44 PM UTC-7, Lynn McGuire wrote:
Does the OPEN function in GNU Fortran support Unicode file names ?
And Unicode file paths ?
Using trial and no error, it seems that 4.1.2 and 6.3.0 can do it.
I presume you have to use it on a file system that supports them.
open(unit=1,file='🦛🐦🐑🐑')
write(1,*) '🦛🐦🐑🐑'
end
On Thursday, July 15, 2021 at 1:18:47 AM UTC-4, gah4 wrote:
With modern Fortran, it'll be better to do along the following the lines:
integer, parameter :: ck = selected_char_kind('ISO_10646')
integer :: lun
.
open( unit=lun, file=ck_'🦛🐦🐑🐑', encoding='utf-8', ..)
write( lun, fmt=.. ) ck_'🦛🐦🐑🐑'
On Thursday, July 15, 2021 at 7:15:35 AM UTC-7, FortranFan wrote:
On Thursday, July 15, 2021 at 1:18:47 AM UTC-4, gah4 wrote:
(after I wrote)
(snip)
With modern Fortran, it'll be better to do along the following the lines:
integer, parameter :: ck = selected_char_kind('ISO_10646')
integer :: lun
.
open( unit=lun, file=ck_'🦛🐦🐑🐑', encoding='utf-8', ..)
write( lun, fmt=.. ) ck_'🦛🐦🐑🐑'
OK, now we have to actually figure it out.
(Including what the question left out.)
And as I noted, it depends on the file system.
The computer I tried first uses the ext2 file system. Like many Unix and Unix-like
file systems, allows all bytes except '/' and '\0' in names. So, UTF-8 bytes will
go through like any other bytes. (And, maybe important, illegal UTF-8 byte combinations will go through, too.)
More often I work on an NFS mounted file system, where the server seems to
be using ext4. (I never checked this before.) As above, all bytes except '/' and '\0'.
I presume NFS will pass them through.
The computer I write this on has hfs+, which it seems uses UTF-16 for names. This computer also mounts the above mentioned NFS partition, which is where
I tried compiling the second time. hfs+ does allow all characters, including '\0'
and '/', though the OS might disallow the latter. I don't think Unix-like systems
can let it though, though NFS should be able to write it.
It seems that newer OS X systems use APFS, which uses Unicode 9.0 stored
as UTF-8. I don't have gfortran on that one. I think that means that it will
disallow byte combinations that are not legal UTF-8. And again, no restrictions
on '\0' or '/'.
So, the question is not only what gfortran allows, but what the underlying file system allows, and whether gfortran adjusts based on the file system.
And since we are writing them here, what the web interface allows through when we post things.
Does the OPEN function in GNU Fortran support Unicode file names ?
...
...To my understanding, gfortran accepts file names without examining
if the characters are ASCII or UTF-8.
...
On 16/07/2021 14:18, Ev. Drikos wrote:
...To my understanding, gfortran accepts file names without examining
if the characters are ASCII or UTF-8.
...
@everyone
Here is a fresh program along with the execution steps (the program
couldn't echo the '*' to the file below in Windows-8.1).
...
I am not sure which '*' it couldn't echo, but if PowerShell is anything
like a Unix shell, it expands * using the file names in the current
(or otherwise appropriate) directory. Unless in quotes or apostrophes.
As for the actual program, it might be that PowerShell doesn't process
the '*' right, or it might not get into the argument list the right way,
or the I/O library might not be able to write one out, or ...
On 20/07/2021 22:45, gah4 wrote:
I am not sure which '*' it couldn't echo, but if PowerShell is anything like a Unix shell, it expands * using the file names in the current
(or otherwise appropriate) directory. Unless in quotes or apostrophes.
Unfortunately, the program can't process this, which works ie in macOS:
PS C:\Users\suser> .\fecho.exe αστρονομια.txt '*'
On 21/07/2021 09:34, gah4 wrote:
As for the actual program, it might be that PowerShell doesn't processIt turned out that the problem is reproduced in the home directory of
the '*' right, or it might not get into the argument list the right way,
or the I/O library might not be able to write one out, or ...
the user, where the '*' is expanded to all directory files. In my case
the program had 29 arguments. Likely, it's a bug in a Windows-8.1 app.
On 21/07/2021 10:58, gah4 wrote:
...
I tried
echo *
and got an actual
*
...
Just posted a question to the Cygwin forum: https://cygwin.com/pipermail/cygwin/2021-July/248946.html
Ev. Drikos
...
I tried
echo *
and got an actual
*
...
ECHO is a built-in command in Windows. There is also an echo.exe in
Cygwin, and this one expands arguments with wildcards.
When you type "echo *" in a Cygwin shell, you will get the expansion you appear to want.
...
I think I only used PS one time before, and thought that it was supposed to have Unix-like features. It seems to have some features, but not that one.
In Unix, the expansion is done by the shell, not by the command.
But I suppose that would confuse Windows users too much.
...
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 159 |
Nodes: | 16 (0 / 16) |
Uptime: | 99:16:26 |
Calls: | 3,209 |
Files: | 10,563 |
Messages: | 3,009,786 |