1 #ifndef R_UTF8_H 2 #define R_UTF8_H 3 4 /* For RStrEnc definition */ 5 #include "r_str.h" 6 7 typedef struct { ut32 from, to; const char *name; } RUtfBlock; 8 // extern const RUtfBlock r_utf_blocks[]; 9 10 typedef ut32 RRune; 11 R_API int r_utf8_encode(ut8 *ptr, const RRune ch); 12 R_API int r_utf8_decode(const ut8 *ptr, int ptrlen, RRune *ch); 13 R_API int r_utf8_encode_str(const RRune *str, ut8 *dst, const int dst_length); 14 R_API int r_utf8_size(const ut8 *ptr); 15 R_API int r_utf8_strlen(const ut8 *str); 16 R_API int r_isprint(const RRune c); 17 R_API char *r_utf16_to_utf8_l(const wchar_t *wc, int len); 18 R_API const char *r_utf_block_name(int idx); 19 R_API wchar_t *r_utf8_to_utf16_l(const char *cstring, int len); 20 R_API int r_utf_block_idx (RRune ch); 21 R_API int *r_utf_block_list (const ut8 *str, int len, int **freq_list); 22 R_API RStrEnc r_utf_bom_encoding(const ut8 *ptr, int ptrlen); 23 #define r_utf16_to_utf8(wc) r_utf16_to_utf8_l ((wchar_t *)wc, -1) 24 #define r_utf8_to_utf16(cstring) r_utf8_to_utf16_l ((char *)cstring, -1) 25 #if __WINDOWS__ 26 R_API char *r_acp_to_utf8_l(const char *str, int len); 27 R_API char *r_utf8_to_acp_l(const char *str, int len); 28 #define r_acp_to_utf8(str) r_acp_to_utf8_l ((char *)str, -1) 29 #define r_utf8_to_acp(cstring) r_utf8_to_acp_l ((char *)cstring, -1) 30 #endif // __WINDOWS__ 31 32 #endif // R_UTF8_H 33