diff options
author | Matheus Tavares <matheus.bernardino@usp.br> | 2021-05-04 13:27:33 -0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-05-05 12:26:36 +0900 |
commit | 2fa3cbadcdc63c3a723c2fd490f1d84552854bee (patch) | |
tree | 877a4d690e319356a223f203b3eb283b4b519e6e /t/lib-encoding.sh | |
parent | parallel-checkout: add tests related to path collisions (diff) | |
download | tgif-2fa3cbadcdc63c3a723c2fd490f1d84552854bee.tar.xz |
t0028: extract encoding helpers to lib-encoding.sh
The following patch will add tests outside t0028 which will also need to
re-encode some strings. Extract the auxiliary encoding functions from
t0028 to a common lib file so that they can be reused.
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/lib-encoding.sh')
-rw-r--r-- | t/lib-encoding.sh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/t/lib-encoding.sh b/t/lib-encoding.sh new file mode 100644 index 0000000000..2dabc8c73e --- /dev/null +++ b/t/lib-encoding.sh @@ -0,0 +1,25 @@ +# Encoding helpers + +test_lazy_prereq NO_UTF16_BOM ' + test $(printf abc | iconv -f UTF-8 -t UTF-16 | wc -c) = 6 +' + +test_lazy_prereq NO_UTF32_BOM ' + test $(printf abc | iconv -f UTF-8 -t UTF-32 | wc -c) = 12 +' + +write_utf16 () { + if test_have_prereq NO_UTF16_BOM + then + printf '\376\377' + fi && + iconv -f UTF-8 -t UTF-16 +} + +write_utf32 () { + if test_have_prereq NO_UTF32_BOM + then + printf '\0\0\376\377' + fi && + iconv -f UTF-8 -t UTF-32 +} |