Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

ASCII Character Codes

bbeyer
Novice
1,999 Views
Is there a way to use the extended ASCII Character Codes (128-255) within CVF 6.0 and within program output? I am interested in using some of the greek symbols. Thanks for any advice.
0 Kudos
4 Replies
Jugoslav_Dujic
Valued Contributor II
1,999 Views
Program output to where? Console? Dialog? Window?

Jugoslav
0 Kudos
bbeyer
Novice
1,999 Views
I am trying to use these extended characters in formatted text output written to files, as well as in the comments within the source code itself within the text editor of CVF.
0 Kudos
Jugoslav_Dujic
Valued Contributor II
1,999 Views
Within your source code, you can type extended characters if the current script of the source font contains them. You can set the font using Tools/Options/Format/Source Windows/Font. You have to choose font script for one code page (as source files are not UNICODE). For example, on my computer I see "CE", "Cyr", and "Greek" versions of Courier New. This setting only affects characters 128-255, as the first 128 are always the same (ASCII) for every code page.

As for the output, it's trickier. Have in mind that whatever you write into a file is just a sequence of bytes... and bytes can have only values 0-255. For example, big Greek letter Sigma has unicode value of 0x3A3, but in Greek code page it is mapped to position 211 (0xD3). So, the question is not "whether I can display Sigma in a text file?", but "what should I do to have 211 interpreted as Sigma?". So, if you open the file containing that 211 in editor with e.g. Courier New Greek font, you'll see Sigma; if it's Courier New Western, you'll see E grave (); on Central European, it's C Caron etc.

See also this little program which uses SetConsoleOutputCP API to change console code page, then displays characters 128-255 in four different scripts. It works on Windows 2000, as it's Unicode under the hub (I doubt it will work on 9x/ME) and only if the console output font is set to a Unicode font (Lucida Console e.g.)
Program CodePage
   Use Kernel32
   Use User32
   Implicit None
   Character*129 Text
   Integer*4 iCodePage, iRet
   Logical*4 lRet
   integer i

   do i = 128,255
      text(i-127:i-127) = char(i)
   end do
   do iCodePage = 1250, 1253
      iRet = SetConsoleOutputCP(iCodePage)
      If ( iRet .gt. 0 ) Then
         Write (*,"(' CodePage=',i6)") iCodePage
         write(*,"(A)") text
      End If
   End do
End Program CodePage
Actually, SetConsoleOutputCP affects the script of the font used to display console text. Default bitmapped font (Terminal) does not support scripts.

Jugoslav


0 Kudos
bbeyer
Novice
1,999 Views
Thanks for your help Jugoslav.
0 Kudos
Reply