From 0e18bcd5e937b9e5857892e7f5c80c3c5b1da5d4 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 18 Oct 2012 22:41:56 -0700 Subject: reencode_string(): introduce and use same_encoding() Callers of reencode_string() that re-encodes a string from one encoding to another all used ad-hoc way to bypass the case where the input and the output encodings are the same. Some did strcmp(), some did strcasecmp(), yet some others when converting to UTF-8 used is_encoding_utf8(). Introduce same_encoding() helper function to make these callers use the same logic. Notably, is_encoding_utf8() has a work-around for common misconfiguration to use "utf8" to name UTF-8 encoding, which does not match "UTF-8" hence strcasecmp() would not consider the same. Make use of it in this helper function. Signed-off-by: Junio C Hamano --- utf8.h | 1 + 1 file changed, 1 insertion(+) (limited to 'utf8.h') diff --git a/utf8.h b/utf8.h index 3c0ae7624e..93ef60042c 100644 --- a/utf8.h +++ b/utf8.h @@ -7,6 +7,7 @@ int utf8_width(const char **start, size_t *remainder_p); int utf8_strwidth(const char *string); int is_utf8(const char *text); int is_encoding_utf8(const char *name); +int same_encoding(const char *, const char *); int strbuf_add_wrapped_text(struct strbuf *buf, const char *text, int indent, int indent2, int width); -- cgit v1.2.3