Re: sed error message reports byte position instead of char position when program contains UTF-8

John Cowan <[email protected]>
Newsgroups gmane.comp.gnu.utils.bugs
Message-ID <[email protected]>
Eli Zaretskii scripsit:

> AFAIK, Sed uses bytes, not characters.

Definitely not.  Look at the following:

$ echo $LANG
en_US.UTF-8
$ cat >foo
föö
(Ctrl-D)
$ wc -c foo
6 foo
(including the newline; therefore the file is UTF-8)
$ sed -n '/^...$/p' <foo
föö
$ sed -n '/^.....$/p' <foo
$

So the regex matches 3 characters, not 5 bytes.

-- 
We call nothing profound                        [email protected]
that is not wittily expressed.                  John Cowan
        --Northrop Frye (improved)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.