dummy-link

StrFs

Julia packages for strings with fixed maximum number of bytes.

Readme

StrFs

Lifecycle Build Status codecov.io

Julia packages for strings with fixed maximum number of bytes.

Overview

StrF{S} <: AbstractString can be used for strings up to S bytes in UTF-8 encoding. When the string has less than that many bytes, it is terminated with a 0x00.

This mirrors the way Stata DTA files encode fixed length strings (str#), but other applications may also find this useful. StrF{S} strings are implemented by wrapping an SVector{S,UInt8}, with the potential efficiency gains that entails.

Examples

julia> using StrFs

julia> gender = [strf"male", strf"female"]
2-element Array{StrF{6},1}:
 "male"
 "female"

julia> gender[1] == "male"
true

julia> issorted(gender, rev = true)
true

julia> motto = StrF{6}("ηβπ")          # uses all bytes
"ηβπ"

julia> sizeof(motto)
6

julia> length(motto)
3

julia> motto == StrF{10}("ηβπ")        # 0x00 at byte 7
true

Related

See StataDTAFiles.jl.

First Commit

09/23/2018

Last Touched

about 1 month ago

Commits

23 commits