Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Encode 7-bit ASCII data into the buffer out[], which must be at least
- ** "len" bytes in length. The encoded data will have the same size as
- ** the decoded data. You must append a 0 byte to terminate the string.
- ** The buffers in[] and out[] may be the same. Call this function again
- ** to decode. Return the length encoded, or -1 on error.
- */
- int ascii7enc(char *out, const char *in, int len)
- {
- int ct = len;
- if (!in || !out || len < 0) return -1;
- while (ct-- > 0)
- {
- char ch = (*in == 0 || *in == '\'' || *in == 0x80 || *in == '\''^0x80)?
- (*in++ ^ 0x80): *in++;
- *out++ = ch;
- }
- return len;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement