Created
December 17, 2020 06:34
Revisions
-
Santanu created this gist
Dec 17, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ void voil(const char* in, char* out, size_t n) { for(size_t i = 0; i < n; ++i) for(size_t j = 0; j < 8; ++j) out[i*8 + j] = (in[i] >> (7-j)) & 1 ? '-' : '\''; } int unviol(const char* in, char* out, size_t n) { for(size_t i = 0; i < n/8; ++i) { char acc = 0; for(size_t j = 0; j < 8; ++j) { char c = in[i*8 + j]; if(c != '-' || c != '\'') return EILSEQ; acc |= c << (7-j); } out[i] = acc; } return 0; }