Re: bug report: symbolic-ref --short command echos the wrong text while use Chinese language
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Feb 14, 2023, 06:05 UTC
- Message-ID
- <CAPig+cQx24PRUsEjEcnuDtokS02SS3n_dUi8MO=WJbBazget8g@mail.gmail.com>
- In-Reply-To
- <xmqq7cwk955b.fsf@gitster.g>
On Tue, Feb 14, 2023 at 12:40 AM Junio C Hamano <gitster@pobox.com> wrote:
Show 12 quoted lines
> Eric Sunshine <sunshine@sunshineco.com> writes: > > sscanf() seems to be the culprit. If I set LANG, then I get the same > > result as you get: > > > > $ LANG=zh-CN.UTF-8 git symbolic-ref --short HEAD > > warning: strlen(refname) = 39 > > warning: strlen(short_name) = 28 > > 测试-加-增加-加-增加 > > Well, that's ... criminal. > > I wonder if LANG=$ANY_VALID_ONE.UTF-8 would work the same way.
Um, I suppose you are pointing out that I messed up by using invalid LANG code "zh-CN"?
Using (presumably) valid LANG codes results in the buggy truncated output, but "LANG=C" produces the correct result:
$ for i in C en_US fr_FR de_DE ru_RU zh_CN; do printf "$i: " && LANG=$i.UTF-8 git symbolic-ref --short HEAD; done C: 测试-加-增加-加-增加 en_US: 测试-? fr_FR: 测试-? de_DE: 测试-? ru_RU: 测试-? zh_CN: 测试-?