From: Daniel Shahaf <d.s@daniel.shahaf.name>
To: 정누리 <jnooree@gmail.com>
Cc: zsh-workers@zsh.org
Subject: Re: zsh/pcre has errors with unicode bytes
Date: Mon, 13 Jul 2020 14:02:38 +0000 [thread overview]
Message-ID: <20200713140238.1d6f4ebf@tarpaulin.shahaf.local2> (raw)
In-Reply-To: <DF33AF21-A6D3-46E6-831D-1EC15049E975@gmail.com>
정누리 wrote on Mon, 13 Jul 2020 11:53 +0900:
> $ LC_ALL='C'
> $ str='Hi😊'
> $ for (( i = 1; i <= ${#str}; ++i )); do
> byte="$str[i]"
> [[ $byte -pcre-match [a-zA-Z0-9] ]] && echo $byte || echo 'no match'
> done
> >> H
> i
> zsh: pcre_exec() error [-10]
From /usr/include/pcre.h on my system:
#define PCRE_ERROR_BADUTF8 (-10) /* Same for 8/16/32 */
#define PCRE_ERROR_BADUTF16 (-10) /* Same for 8/16/32 */
#define PCRE_ERROR_BADUTF32 (-10) /* Same for 8/16/32 */
So pcre expects the pattern to be a Unicode string, despite the locale.
Actually, wait. We don't know what the locale is. I don't build PCRE,
but could you try that again with «export LC_ALL='C'» at the start?
If that doesn't force it to use ASCII, try unsetting the MULTIBYTE
option. See zpcre_utf8_enabled() (in Src/Modules/pcre.c).
Cheers,
Daniel
> no match
> zsh: pcre_exec() error [-10]
> no match
> zsh: pcre_exec() error [-10]
> no match
> zsh: pcre_exec() error [-10]
> no match
>
> Thanks for reading.
next prev parent reply other threads:[~2020-07-13 14:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-13 2:53 정누리
2020-07-13 14:02 ` Daniel Shahaf [this message]
2020-07-15 7:43 ` Jun T
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200713140238.1d6f4ebf@tarpaulin.shahaf.local2 \
--to=d.s@daniel.shahaf.name \
--cc=jnooree@gmail.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).