Johannes Schindelin | 9e83266 | 2006-12-22 22:06:08 +0100 | [diff] [blame] | 1 | #ifndef GIT_UTF8_H |
| 2 | #define GIT_UTF8_H |
| 3 | |
Junio C Hamano | 396ccf1 | 2008-01-06 19:02:22 -0800 | [diff] [blame] | 4 | typedef unsigned int ucs_char_t; /* assuming 32bit int */ |
| 5 | |
Nguyễn Thái Ngọc Duy | 1640632 | 2013-04-19 09:08:52 +1000 | [diff] [blame] | 6 | size_t display_mode_esc_sequence_len(const char *s); |
Junio C Hamano | 44b25b8 | 2008-01-02 01:49:58 -0800 | [diff] [blame] | 7 | int utf8_width(const char **start, size_t *remainder_p); |
Nguyễn Thái Ngọc Duy | 2bc1e7e | 2013-04-19 09:08:45 +1000 | [diff] [blame] | 8 | int utf8_strnwidth(const char *string, int len, int skip_ansi); |
Geoffrey Thomas | 8a9391e | 2009-01-30 04:41:28 -0500 | [diff] [blame] | 9 | int utf8_strwidth(const char *string); |
Johannes Schindelin | 9e83266 | 2006-12-22 22:06:08 +0100 | [diff] [blame] | 10 | int is_utf8(const char *text); |
Junio C Hamano | 677cfed | 2006-12-30 12:20:43 -0800 | [diff] [blame] | 11 | int is_encoding_utf8(const char *name); |
Junio C Hamano | 0e18bcd | 2012-10-18 22:41:56 -0700 | [diff] [blame] | 12 | int same_encoding(const char *, const char *); |
Jeff King | 4621085 | 2013-07-09 20:18:40 -0400 | [diff] [blame] | 13 | __attribute__((format (printf, 2, 3))) |
Jiang Xin | c082196 | 2013-02-09 14:31:09 +0800 | [diff] [blame] | 14 | int utf8_fprintf(FILE *, const char *, ...); |
Junio C Hamano | 677cfed | 2006-12-30 12:20:43 -0800 | [diff] [blame] | 15 | |
Steffen Prohaska | e0db176 | 2012-12-11 06:59:22 +0100 | [diff] [blame] | 16 | void strbuf_add_wrapped_text(struct strbuf *buf, |
Johannes Schindelin | a94410c | 2008-11-10 18:47:00 +0100 | [diff] [blame] | 17 | const char *text, int indent, int indent2, int width); |
Steffen Prohaska | e0db176 | 2012-12-11 06:59:22 +0100 | [diff] [blame] | 18 | void strbuf_add_wrapped_bytes(struct strbuf *buf, const char *data, int len, |
Jeff King | 98acc83 | 2011-02-23 04:50:19 -0500 | [diff] [blame] | 19 | int indent, int indent2, int width); |
Nguyễn Thái Ngọc Duy | a7f01c6 | 2013-04-19 09:08:51 +1000 | [diff] [blame] | 20 | void strbuf_utf8_replace(struct strbuf *sb, int pos, int width, |
| 21 | const char *subst); |
Johannes Schindelin | 9e83266 | 2006-12-22 22:06:08 +0100 | [diff] [blame] | 22 | |
Junio C Hamano | b45974a | 2006-12-23 23:36:55 -0800 | [diff] [blame] | 23 | #ifndef NO_ICONV |
Nguyễn Thái Ngọc Duy | b782bba | 2013-04-19 09:08:46 +1000 | [diff] [blame] | 24 | char *reencode_string_iconv(const char *in, size_t insz, |
| 25 | iconv_t conv, int *outsz); |
| 26 | char *reencode_string_len(const char *in, int insz, |
| 27 | const char *out_encoding, |
| 28 | const char *in_encoding, |
| 29 | int *outsz); |
Junio C Hamano | b45974a | 2006-12-23 23:36:55 -0800 | [diff] [blame] | 30 | #else |
Nguyễn Thái Ngọc Duy | b782bba | 2013-04-19 09:08:46 +1000 | [diff] [blame] | 31 | #define reencode_string_len(a,b,c,d,e) NULL |
Junio C Hamano | b45974a | 2006-12-23 23:36:55 -0800 | [diff] [blame] | 32 | #endif |
| 33 | |
Nguyễn Thái Ngọc Duy | b782bba | 2013-04-19 09:08:46 +1000 | [diff] [blame] | 34 | static inline char *reencode_string(const char *in, |
| 35 | const char *out_encoding, |
| 36 | const char *in_encoding) |
| 37 | { |
| 38 | return reencode_string_len(in, strlen(in), |
| 39 | out_encoding, in_encoding, |
| 40 | NULL); |
| 41 | } |
| 42 | |
Kirill Smelkov | 6cd3c05 | 2013-03-07 14:55:07 +0400 | [diff] [blame] | 43 | int mbs_chrlen(const char **text, size_t *remainder_p, const char *encoding); |
| 44 | |
Jeff King | 6162a1d | 2014-12-15 17:56:59 -0500 | [diff] [blame] | 45 | /* |
| 46 | * Returns true if the the path would match ".git" after HFS case-folding. |
| 47 | * The path should be NUL-terminated, but we will match variants of both ".git\0" |
| 48 | * and ".git/..." (but _not_ ".../.git"). This makes it suitable for both fsck |
| 49 | * and verify_path(). |
| 50 | */ |
| 51 | int is_hfs_dotgit(const char *path); |
| 52 | |
Johannes Schindelin | 9e83266 | 2006-12-22 22:06:08 +0100 | [diff] [blame] | 53 | #endif |