]>
Commit | Line | Data |
---|---|---|
c63539ff ML |
1 | .. |
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. | |
5 | ||
6 | .. index:: SELECTED_CHAR_KIND, character kind, kind, character | |
7 | ||
8 | .. _selected_char_kind: | |
9 | ||
10 | SELECTED_CHAR_KIND --- Choose character kind | |
11 | ******************************************** | |
12 | ||
13 | .. function:: SELECTED_CHAR_KIND(NAME) | |
14 | ||
15 | ``SELECTED_CHAR_KIND(NAME)`` returns the kind value for the character | |
16 | set named :samp:`{NAME}`, if a character set with such a name is supported, | |
17 | or -1 otherwise. Currently, supported character sets include | |
18 | 'ASCII' and 'DEFAULT', which are equivalent, and 'ISO_10646' | |
19 | (Universal Character Set, UCS-4) which is commonly known as Unicode. | |
20 | ||
21 | :param NAME: | |
22 | Shall be a scalar and of the default character type. | |
23 | ||
24 | Standard: | |
25 | Fortran 2003 and later | |
26 | ||
27 | Class: | |
28 | Transformational function | |
29 | ||
30 | Syntax: | |
31 | .. code-block:: fortran | |
32 | ||
33 | RESULT = SELECTED_CHAR_KIND(NAME) | |
34 | ||
35 | Example: | |
36 | .. code-block:: fortran | |
37 | ||
38 | program character_kind | |
39 | use iso_fortran_env | |
40 | implicit none | |
41 | integer, parameter :: ascii = selected_char_kind ("ascii") | |
42 | integer, parameter :: ucs4 = selected_char_kind ('ISO_10646') | |
43 | ||
44 | character(kind=ascii, len=26) :: alphabet | |
45 | character(kind=ucs4, len=30) :: hello_world | |
46 | ||
47 | alphabet = ascii_"abcdefghijklmnopqrstuvwxyz" | |
48 | hello_world = ucs4_'Hello World and Ni Hao -- ' & | |
49 | // char (int (z'4F60'), ucs4) & | |
50 | // char (int (z'597D'), ucs4) | |
51 | ||
52 | write (*,*) alphabet | |
53 | ||
54 | open (output_unit, encoding='UTF-8') | |
55 | write (*,*) trim (hello_world) | |
3ed1b4ce | 56 | end program character_kind |