I have always been frustrated about C not having a proper String type that most modern languages have nowadays. I love the simplicity of C, but there are some features that I would really like to have in it, and this is one of them.

Since I made a small library (just one .c file) that you can use to make the experience of working with strings in C just a little better, I would like to show it to you here.

For the impatient, this is the general idea:

struct str_view {
    const u8       *data;
    usize           len;
};
struct str_owned {
    u8             *data;
    usize           len;
};

But before getting into the library itself, I will go over how “strings” work in C and why I find them annoying, what the issues are with this model, and then it will be easier to explain why I decided to take the route that I took.