Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug: Unicode character of zsh module will become weird characters
- X-seq: zsh-workers 52932
- From: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>
- To: "Wu, Zhenyu" <wuzhenyu@xxxxxxxx>, zsh-workers@xxxxxxx
- Subject: Re: Bug: Unicode character of zsh module will become weird characters
- Date: Mon, 13 May 2024 10:51:18 +0100 (BST)
- Archived-at: <https://zsh.org/workers/52932>
- Importance: Normal
- In-reply-to: <t6jmrshbviujvvb4i3doaaqbo52bwccx2e27v2fgyvitx22x43@tkgdvxkrays5>
- List-id: <zsh-workers.zsh.org>
- References: <t6jmrshbviujvvb4i3doaaqbo52bwccx2e27v2fgyvitx22x43@tkgdvxkrays5>
> On 11/05/2024 14:40 BST Wu, Zhenyu <wuzhenyu@xxxxxxxx> wrote:
> ```zsh
> % git clone --depth=1 https://github.com/zsh-users/zsh
> % cd zsh
> % sed -i 's/strparam = ztrdup("example");/strparam = ztrdup("你好");/' Src/Modules/example.c
> % autoreconf -vif
> % ./configure
> % make
> ```
I think The problem's actually here. Zsh has a special encoding of
strings internally to avoid confusion between normal strings and
tokenised strings. This is because special characters are mixed in with
normal characters in strings inside the code. This system is known as
"metafication". This means you have to be careful when creating strings
to be stored inside the system. In fact, this is usually only a problem
if strings contain byte 0x80, so it can be a bit of a surprise when you
see it.
If you're doing normal input and output this should work automatically,
but you're updating the source code directly. Try changing the line in
the example file to:
strparam = metafy("你好", strlen("你好"), META_DUP);
and see if that works --- looks OK to me with a quick test.
cheers
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author