a pure Fortran 2003+ library providing an OOP
stringtype with Python-like methods for modern Fortran projects.
🔤 Rich String APIupper, lower, camelcase, snakecase, split, join, replace, search, unique — Python-like methods on modern Fortran strings |
🔢 Number Casting Assign any PENF integer or real kind directly to a string; cast back with to_number(kind=...) at compile-time |
📁 File & Path I/Oread_file, write_file, read_line, write_line, basedir, basename, extension, glob — batteries included |
🎨 Encoding & Color Base64 encode/decode via BeFoR64; ANSI terminal colorize via FACE |
|---|---|---|---|
| ⚡ Pure & Elemental Almost all methods are pure or elemental — thread-safe, no side effects |
🔗 Seamless Interop Overloaded =, //, and comparison operators — string is a drop-in for standard character |
🔓 Multi-licensed GPL v3 · BSD 2/3-Clause · MIT |
📦 Multiple build systems fpm, FoBiS, CMake, Make |
For full documentations (guide, tutorial, examples, etc...) see the StringiFor website.
- Stefano Zaghi — @szaghi
Contributions are welcome — see the Contributing page.
This project is distributed under a multi-licensing system:
- FOSS projects: GPL v3
- Closed source / commercial: BSD 2-Clause, BSD 3-Clause, or MIT
Anyone interested in using, developing, or contributing to this project is welcome — pick the license that best fits your needs.
use stringifor
implicit none
type(string) :: s
s = 'Hello, World!'
print "(A)", s%upper()//'' ! HELLO, WORLD!
print "(A)", s%replace(old='World', new='Fortran')//'' ! Hello, Fortran!
print "(A)", s%camelcase()//'' ! Hello,World!
s = 3.14159_R8P
print "(A)", s//'' ! +3.14159000000000E+00
print "(L1)", s%is_real() ! TStandalone — clone, fetch dependencies, and build:
git clone https://github.com/szaghi/StringiFor && cd StringiFor
FoBiS.py fetch # fetch PENF, FACE, BeFoR64
FoBiS.py build -mode stringifor-static-gnu # build static libraryOr install directly in one command:
FoBiS.py install szaghi/StringiFor -mode static-gnu
FoBiS.py install szaghi/StringiFor -mode static-gnu --prefix /path/to/prefixAs a project dependency — declare StringiFor in your fobos and run fetch:
[dependencies]
deps_dir = src/third_party
StringiFor = https://github.com/szaghi/StringiForFoBiS.py fetch # fetch and build
FoBiS.py fetch --update # re-fetch and rebuildAdd to your fpm.toml:
[dependencies]
StringiFor = { git = "https://github.com/szaghi/StringiFor" }fpm build
fpm testcmake -B build && cmake --build buildmake # static library
make TESTS=yes # build and run tests