Skip to content

Features

Design Goals

GoalDescription
Seamless interchangeabilityWorks transparently with standard character variables via overloaded //, =, and comparison operators
Rich built-in methodssplit, replace, join, basename, camelcase, to_number, and many more as type-bound procedures
Low memory consumptionOnly one character(kind=CK, len=:), allocatable member — arrays of strings can hold elements of different lengths
SafeAlmost all methods are elemental or pure
RobustTest-Driven Developed — a comprehensive doctest suite is embedded directly in the source

String Manipulation

  • Case conversion: upper, lower, swapcase, capitalize, camelcase, snakecase, startcase
  • Search and replace: replace, search, index, count, scan, verify
  • Splitting and joining: split, split_chunked, partition, join, strjoin
  • Padding and trimming: fill, strip, adjustl, adjustr, trim
  • Transformation: reverse, unique, insert, slice, escape, unescape
  • Encoding: encode / decode (Base64 via BeFoR64)
  • Terminal output: colorize (ANSI styles via FACE)

Number Casting

  • Assign any PENF integer or real kind directly to a string via overloaded assignment(=)
  • Cast back with to_number(kind=...) — supports all PENF kinds: I1P, I2P, I4P, I8P, R4P, R8P, R16P
  • Inquiry methods: is_number, is_integer, is_real, is_digit

File and Path Utilities

  • Read/write files line-by-line or as streams: read_file, write_file, read_line, read_lines, write_line, write_lines
  • Path components: basedir, basename, extension
  • File-system glob: glob
  • Unique temporary names: tempname

Operators

OperatorReturnsNotes
=From character, string, or any PENF numeric kind
//characterEnables seamless use with Fortran intrinsics
.cat.stringConcatenation keeping the string type
==, /=logicalEquality / inequality
<, <=, >=, >logicalLexicographic comparison

Fortran Built-in Replacements

Generic interfaces that accept type(string) in place of character:

adjustl · adjustr · count · index · len_trim · repeat · scan · trim · verify

Compiler Support

CompilerMinimum VersionStatus
GNU gfortran≥ 9.2.0Full support
Intel ifort / ifx≥ 19.0.4Full support
IBM XLNot tested
g95Not tested
NAGNot tested
PGINot tested