Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/utf8.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2012-12-08 02:10:56 +0400
committerJunio C Hamano <gitster@pobox.com>2012-12-08 02:10:56 +0400
commitfff26a68053022a2cbc39142c7c6f6d016837058 (patch)
tree1ad5a3cd1a135213b3694f11fdcb52bcddec51b9 /utf8.c
parent6a402843c2bc0a72fb70c8795aee523d7f1582d3 (diff)
parent0e18bcd5e937b9e5857892e7f5c80c3c5b1da5d4 (diff)
Merge branch 'jc/same-encoding' into maint
Various codepaths checked if two encoding names are the same using ad-hoc code and some of them ended up asking iconv() to convert between "utf8" and "UTF-8". The former is not a valid way to spell the encoding name, but often people use it by mistake, and we equated them in some but not all codepaths. Introduce a new helper function to make these codepaths consistent. * jc/same-encoding: reencode_string(): introduce and use same_encoding()
Diffstat (limited to 'utf8.c')
-rw-r--r--utf8.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/utf8.c b/utf8.c
index 28791a7c31..5c61bbe113 100644
--- a/utf8.c
+++ b/utf8.c
@@ -423,6 +423,13 @@ int is_encoding_utf8(const char *name)
return 0;
}
+int same_encoding(const char *src, const char *dst)
+{
+ if (is_encoding_utf8(src) && is_encoding_utf8(dst))
+ return 1;
+ return !strcasecmp(src, dst);
+}
+
/*
* Given a buffer and its encoding, return it re-encoded
* with iconv. If the conversion fails, returns NULL.