Skip to content

yymmt742/utf8f

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CI


utf8f

Fortran utf-8 functions

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. License
  5. Contact

About The Project

utf8f provides a set of functions useful for handling utf-8 strings in fortran.

(back to top)

Getting Started

Prerequisites

  • gcc >= 9.4.0
  • gfortran >= 9.4.0
  • cmake >= 3.9

Installation

  1. Clone the repo
    git clone https://github.com/yymmt742/utf8f
  2. Build fortran library
    mkdir build && cd build
    cmake ..
    make install

(back to top)

Usage

   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.

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

YYMMT742 - [email protected]

(back to top)