Silverfrost Forums

Welcome to our forums

Reading 'extended' characters (XP vs. Win 7)

26 Oct 2010 4:01 #7088

I have a program running under Vista or Windows 7 (32 bit) that reads single characters from a data file for subsequent display. One of the characters read in (a1) is a 'simple' vertical arrow and this works fine. [I know that some other such characters do not read correctly from file and one needs to use achar() to create them within the program].

However the same program running under XP will not read this character correctly and will not write out to screen such symbols created using achar().

Does anyone know if this is a function of the OS / the fonts installed or otherwise? I have tried compiling and running on XP but this has no effect.

Many Thanks for any ideas..

Bill

27 Oct 2010 12:36 #7090

Bill,

I'm not sure about the difference between achar and char for unusual characters. You could try the following program on both systems and see if there are any differences in either the file or the reading of the file. (The file may have changed when transferred ?) CHARACTER file_name128, CMNAM128, c INTEGER4 ic, iostat, count(0:256), n, nc, na, nz EXTERNAL CMNAM ! ! Open the text file as transparent ! file_name = CMNAM () open (unit =11, & file =file_name, & status='OLD', & form ='UNFORMATTED', & access='TRANSPARENT', & iostat=iostat) write (,) 'Opening file ',trim(file_name),' iostat =',iostat ! ! Read all characters ! count = 0 n = 0 nc = 0 na = 0 nz = 0 ! do read (unit=11, iostat=iostat) c if (iostat /= 0) exit ! n = n+1 ic = ichar(c) count(ic) = count(ic)+1 select case (ic) case (0:31) nc = nc + 1 ! control characters case (32:126) na = na + 1 ! normal character case (127:256) nz = nz + 1 ! other character case default write (,) 'Unrecognised character : ichar =',ic end select end do ! if (iostat == -1) then write (,) n,' characters read from file ',trim(file_name) else write (,) 'end of file after',n,' characters : IOSTAT =',iostat end if write (,) nc, ' control characters' write (,) na, ' normal characters' write (,) nz, ' non-printable characters' write (,2001) 2001 format (/'Count of active characters'/ ' char Count') 2002 format (i5,i8) do ic = 0,256 if (count(ic) < 1) cycle if (ic >= 32 .and. ic ⇐ 126) cycle write (*,2002) ic, count(ic) end do end

28 Oct 2010 4:18 #7101

Many thanks for this - your program does report that characters such as decimal 24 (up arrow when output on Windows 7 / Vista to screen or printer) are of course control characters. (I wanted to denote vertical using non-graphics characters and this worked fine on these OS.)

I can obviously use (slightly less effectively) standard printable characters for this and other purposes but was somewhat surprised the screen / printer output of several such characters differed in OS.

Thanks again

Bill

Please login to reply.