On 30/09/2019 2:57 PM, Arjen Markus wrote:
> ...
>
> So, what is the recommended way of using non-ASCII characters in file names? ...
>
Likely not the recommended way but once I needed to read from a file the
payload of RPM packages with spaces in paths. My choice was to use the
star character, functional in both my Bash script and the RPM utilities.
Whatsoever, you need to find a way to represent well defined paths with
spaces in your file.
The program below worked in macOS with gcc-4.8 and on Win-8.1 with a
binary built by gfortran in Cygwin.
Regards
------------------------------------------------------------------
! create_names.f90 --
! Open files with a non-ASCII name
!
program create_names
implicit none
integer, parameter :: ucs4 = selected_char_kind( 'iso_10646' )
!character(len=40, kind=ucs4) :: name
character(len=40) :: name, iname
integer i
open( 10, file = 'names.txt' )
read( 10, * ) name
do i=1,40
if (name(i:i)=='*') then
iname(i:i)= ' '
else
iname(i:i)=name(i:i)
end if
end do
write( *, * ) '>>', iname,'<<'
open( 20, file = iname )
write( 20, * ) 'Success!'
close( 20 )
close( 10 )
close( 20 )
end program create_names
------------------------------------------------------------------
#To run it in a Windows console, take the required Cygwin libraries:
for t in `/usr/bin/ldd a.exe|grep -o "/usr/bin/cyg.*.dll"` ; \
do cp $t . ; done ;
------------------------------------------------------------------
$ cat names.txt
pi*π.psd
pi*π.psd
------------------------------------------------------------------
$ cat pi\ π.psd
Success!