Skip to content
/ StrFs.jl Public

Julia packages for strings with fixed maximum number of bytes.

License

Notifications You must be signed in to change notification settings

tpapp/StrFs.jl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StrFs.jl

lifecycle build 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.

About

Julia packages for strings with fixed maximum number of bytes.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages