I have a C library that internally handles strings as {len, u8*} with no null termination. It is painful to rewrite these as null terminated char* at API boundary. I think it is still better than forcing a non-standard string type on api consumers.

Has anyone hit on an API design strategy here that's better than converting to char* in practice?

@michaellabbe While this my own code only I enforce it at API boundary, but I provide a macro like this S("My string") that is like this

#define STRING_ENSURE_STRING_LITERAL(x) ("" x "")
#define S(str) ((struct String){ .data = STRING_ENSURE_STRING_LITERAL(str), .length = sizeof(str) - 1, .is_static = 1 })

I also have a string_from_cstr("foo") in case it's really needed, but rarely it isn't I have found.