Thank you for the code. I could port this easily to C and it solved a lot of portability issues for me.
I've added a C implementation in https://github.com/vitaut/zmij/blob/main/zmij.c in case you are interested.
I've added a C implementation in https://github.com/vitaut/zmij/blob/main/zmij.c in case you are interested.