| 1 | #ifndef DATA_LANG_J8_LIBC_H
|
| 2 | #define DATA_LANG_J8_LIBC_H
|
| 3 |
|
| 4 | typedef struct j8_buf_t {
|
| 5 | unsigned char* data;
|
| 6 | int len;
|
| 7 | } j8_buf_t;
|
| 8 |
|
| 9 | // Places an encoded string in out_buf.
|
| 10 | //
|
| 11 | // Caller must free the returned buffer after using it.
|
| 12 | // The buffer has a len, and data is NUL-terminated. These will match
|
| 13 | // because encoded J8 strings can't have NUL bytes in them.
|
| 14 | //
|
| 15 | // Example:
|
| 16 | // j8_buf_t result = {0};
|
| 17 | // EncodeString({"foo", 3}, &result, 1);
|
| 18 | //
|
| 19 | // printf("%s\n", result.data);
|
| 20 | // free(result.data);
|
| 21 | //
|
| 22 | // There are no encoding errors -- this is part of the J8 design!
|
| 23 |
|
| 24 | void J8EncodeString(j8_buf_t in_buf, j8_buf_t* out_buf, int j8_fallback);
|
| 25 |
|
| 26 | void ShellEncodeString(j8_buf_t in_buf, j8_buf_t* out_buf, int ysh_fallback);
|
| 27 |
|
| 28 | #endif // DATA_LANG_J8_LIBC_H
|