Table of Contents
utf8f provides a set of functions useful for handling utf-8 strings in fortran.
- gcc >= 9.4.0
- gfortran >= 9.4.0
- cmake >= 3.9
- Clone the repo
git clone https://github.com/yymmt742/utf8f
- Build fortran library
mkdir build && cd build cmake .. make install
program main
use mod_utf8f
implicit none
print*, utf8f_len("abcde") ! = 5
print*, utf8f_len("あいうえお") ! = 5
print*, utf8f_codepoint("あ") ! = 12354 (0x3042)
print*, utf8f_width("漢") ! = 2
end program main
The following functions are available.
Function | Retrun value | Arguments | Description |
---|---|---|---|
utf8f_len(s) | integer | s (character(*)) | Returns the number of characters in a string. (Unlike the built-in LEN, this is not byte-length.) |
utf8f_codepoint(s) | integer | s (character(*)) | Returns the Unicode code point of the first character in string s. |
utf8f_width(s, is_CJK) | integer | s (character(*)), is_CJK (logical, optional) | Returns the character width displayed in the console. (Based on East Asian Width in Unicode Standard Annex.) |
utf8f_category(s) | character(2) | s (character(*)) | Returns the Unicode General category. |
utf8f_easta_property(s) | character(2) | s (character(*)) | Returns the Unicode East Asian Width property. |
The data contained in this database is compiled from the UCD version 15.1.0.
For details, see the Unicode Character Database.
Distributed under the MIT License. See LICENSE
for more information.
YYMMT742 - [email protected]