a case conversion and detection library in zig
cases supported: camelCase, PascalCase, snake_case, CONSTANT_CASE, kebab-case, Header-Case, lower case, UPPER CASE, Capital Case
uses readers and writers throughout. supports non-allocating and comptime use.
to(case, reader, writer)- converts to case from reader into writerof(text)- returnCaseof text. may be 'unknown'.bufTo(buf, case, text)- writes converted text to buf in specified caseallocTo(allocator, case, text)- allocates a buffer and writes converted text to buffer in specified caseallocToZ()- same as allocTo() but null terminatedcomptimeTo(case, text)- allocates buffer at comptimecomptimeToLen(case, text, len)- same as comptimeTo() but allows user to specify buffer lenlength(case, text)- returns length needed to convert text to caseisCamel(text)- true if text case is camel. similar methods for each caseupper(reader, writer, opts), camel(reader, writer)- conversion functions for each case. upper(), lower() and capital() have an additional opts param.toExt(case, reader, writer, opts)there are variants of all 'to' methods such astoExt(), lengthExt(). these are for upper, lower and capital cases when you want to specify Options.opts: Options- fill - string used to replace non alpha numeric characters. default empty. when empty, don't replace non alpha numeric characters.
- apostrophe - keep / remove. default keep.
- c_api.zig - exports methods similar to most public zig methods above
- case.h
Caseenum guaranteed to be in sync withCaseenum in lib.zig
$ zig build test runs the following
- tests.zig - pretty thorough zig tests which also test the c api methods
- test.c - a small demo program which exercises the c api
$ zig build
creates zig-out/lib/libcase.a and zig-out/include/case.h
- zig package manager support
thanks to cmgriffing for suggesting this