Skip to content

Commit eb12788

Browse files
committed
t3900: ISO-2022-JP has more than one popular variants
When converting from other encodings (e.g. EUC-JP or UTF-8), there are subtly different variants of ISO-2022-JP, all of which are valid. At the end of line or when a run of string switches to 1-byte sequence, ESC ( B can be used to switch to ASCII or ESC ( J can be used to switch to ISO 646:JP (JIS X 0201) but they essentially are the same character set and are used interchangeably. Similarly the set ESC $ @ switches to (JIS X 0208-1978) and ESC $ B switches to (JIS X 0208-1983) are in practice used interchangeably. Depending on the iconv library and the locale definition on the system, a program that converts from another encoding to ISO-2022-JP can produce different byte sequence, and GIT_TEST_CMP (aka "diff -u") will report the difference as a failure. Fix this by converting the expected and the actual output to UTF-8 before comparing when the end result is ISO-2022-JP. The test vector string in t3900/ISO-2022-JP.txt is expressed with ASCII and JIS X 0208-1983, but it can be expressed with any other possible variant, and when converted back to UTF-8, these variants produce identical byte sequences. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 6345d7a commit eb12788

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

t/t3900-i18n-commit.sh

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ test_description='commit and log output encodings'
99

1010
compare_with () {
1111
git show -s $1 | sed -e '1,/^$/d' -e 's/^ //' >current &&
12-
test_cmp current "$2"
12+
case "$3" in
13+
'')
14+
test_cmp "$2" current ;;
15+
?*)
16+
iconv -f "$3" -t utf8 >current.utf8 <current &&
17+
iconv -f "$3" -t utf8 >expect.utf8 <"$2" &&
18+
test_cmp expect.utf8 current.utf8
19+
;;
20+
esac
1321
}
1422

1523
test_expect_success setup '
@@ -103,11 +111,17 @@ done
103111

104112
for J in EUCJP ISO-2022-JP
105113
do
114+
if test "$J" = ISO-2022-JP
115+
then
116+
ICONV=$J
117+
else
118+
ICONV=
119+
fi
106120
git config i18n.logoutputencoding $J
107121
for H in EUCJP ISO-2022-JP
108122
do
109123
test_expect_success "$H should be shown in $J now" '
110-
compare_with '$H' "$TEST_DIRECTORY"/t3900/'$J'.txt
124+
compare_with '$H' "$TEST_DIRECTORY"/t3900/'$J'.txt $ICONV
111125
'
112126
done
113127
done

0 commit comments

Comments
 (0)