{"thread":{"id":"19310","subject":"[PATCH] t3900: ISO-2022-JP has more than one popular variants","startedAt":"2009-05-12T09:29:10Z","lastAt":"2009-05-12T09:29:10Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"113625","messageId":"7vljp28yah.fsf@alter.siamese.dyndns.org","threadId":"19310","inReplyTo":null,"subject":"[PATCH] t3900: ISO-2022-JP has more than one popular variants","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-05-12T09:29:10Z","receivedAt":"2009-05-12T09:29:10Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When converting from other encodings (e.g. EUC-JP or UTF-8), there are\nsubtly different variants of ISO-2022-JP, all of which are valid.  At the\nend of line or when a run of string switches to 1-byte sequence, ESC ( B\ncan be used to switch to ASCII or ESC ( J can be used to switch to ISO\n646:JP (JIS X 0201) but they essentially are the same character set and\nare used interchangeably.  Similarly the set ESC $ @ switches to (JIS X\n0208-1978) and ESC $ B switches to (JIS X 0208-1983) are in practice used\ninterchangeably.\n\nDepending on the iconv library and the locale definition on the system, a\nprogram that converts from another encoding to ISO-2022-JP can produce\ndifferent byte sequence, and GIT_TEST_CMP (aka \"diff -u\") will report the\ndifference as a failure.\n\nFix this by converting the expected and the actual output to UTF-8 before\ncomparing when the end result is ISO-2022-JP.  The test vector string in\nt3900/ISO-2022-JP.txt is expressed with ASCII and JIS X 0208-1983, but it\ncan be expressed with any other possible variant, and when converted back\nto UTF-8, these variants produce identical byte sequences.\n\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n\n * I had to spend some time on an OpenSolaris box at work today X-< so\n   play with git there while waiting for something else to finish.  They\n   seem to produce ESC ( J instead of ESC ( B to switch out of the 2-byte\n   Japanese.\n\n   I had to \"pkg install lang-support-japanese\" to pass this test.\n\n t/t3900-i18n-commit.sh |   18 ++++++++++++++++--\n 1 files changed, 16 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh\nindex 784c31a..5dbbcb6 100755\n--- a/t/t3900-i18n-commit.sh\n+++ b/t/t3900-i18n-commit.sh\n@@ -9,7 +9,15 @@ test_description='commit and log output encodings'\n \n compare_with () {\n \tgit show -s $1 | sed -e '1,/^$/d' -e 's/^    //' >current &&\n-\ttest_cmp current \"$2\"\n+\tcase \"$3\" in\n+\t'')\n+\t\ttest_cmp \"$2\" current ;;\n+\t?*)\n+\t\ticonv -f \"$3\" -t utf8 >current.utf8 <current &&\n+\t\ticonv -f \"$3\" -t utf8 >expect.utf8 <\"$2\" &&\n+\t\ttest_cmp expect.utf8 current.utf8\n+\t\t;;\n+\tesac\n }\n \n test_expect_success setup '\n@@ -103,11 +111,17 @@ done\n \n for J in EUCJP ISO-2022-JP\n do\n+\tif test \"$J\" = ISO-2022-JP\n+\tthen\n+\t\tICONV=$J\n+\telse\n+\t\tICONV=\n+\tfi\n \tgit config i18n.logoutputencoding $J\n \tfor H in EUCJP ISO-2022-JP\n \tdo\n \t\ttest_expect_success \"$H should be shown in $J now\" '\n-\t\t\tcompare_with '$H' \"$TEST_DIRECTORY\"/t3900/'$J'.txt\n+\t\t\tcompare_with '$H' \"$TEST_DIRECTORY\"/t3900/'$J'.txt $ICONV\n \t\t'\n \tdone\n done\n-- \n1.6.3.9.g6345d\n"}]}