2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
10 .. index:: conversion, to integer
12 ICHAR --- Character-to-integer conversion function
13 **************************************************
15 .. function:: ICHAR(C)
17 ``ICHAR(C)`` returns the code for the character in the first character
18 position of ``C`` in the system's native character set.
19 The correspondence between characters and their codes is not necessarily
20 the same across different GNU Fortran implementations.
23 Shall be a scalar ``CHARACTER``, with ``INTENT(IN)``
26 (Optional) An ``INTEGER`` initialization
27 expression indicating the kind parameter of the result.
30 The return value is of type ``INTEGER`` and of kind :samp:`{KIND}`. If
31 :samp:`{KIND}` is absent, the return value is of default integer kind.
34 Fortran 77 and later, with :samp:`{KIND}` argument Fortran 2003 and later
40 .. code-block:: fortran
42 RESULT = ICHAR(C [, KIND])
45 .. code-block:: fortran
50 end program test_ichar
64 - Fortran 77 and later
67 No intrinsic exists to convert between a numeric value and a formatted
68 character string representation -- for instance, given the
69 ``CHARACTER`` value ``'154'``, obtaining an ``INTEGER`` or
70 ``REAL`` value with the value 154, or vice versa. Instead, this
71 functionality is provided by internal-file I/O, as in the following
74 .. code-block:: fortran
78 character(len=10) string, string2
81 ! Convert a string to a numeric value
82 read (string,'(I10)') value
85 ! Convert a value to a formatted string
86 write (string2,'(I10)') value