-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
1 parent
6a7bc9d
commit 2fa3cba
Showing
2 changed files
with
26 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters