[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Locale not Obeyed by Parameter Expansion with Pattern Substitution
From: |
Chet Ramey |
Subject: |
Re: Locale not Obeyed by Parameter Expansion with Pattern Substitution |
Date: |
Wed, 20 Nov 2019 09:11:59 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.2.2 |
On 11/17/19 4:25 AM, Chris Carlen wrote:
Bash Version: 5.0
Patch Level: 0
Release Status: release
Description:
UTF-8 multibyte char string split into bytes rather than characters.
Repeat-By:
#!/bin/bash
shopt -s extglob
LC_ALL="en_US.UTF-8"
# E.g., normal/expected behavior:
# Create a string:
A=abc
# Replace left virtual empty strings with spaces, putting separated
# chars into positional parameters, then print them quoted:
set -- ${A//?()/ }
echo "${@@Q}" #-> 'a' 'b' 'c'
# E.g., abnormal behavior:
# write 'REVERSE PILCROW SIGN' to B, then repeat as above:
printf -v B '\u204B'
set -- ${B//?()/ }
echo "${@@Q}" #-> $'\342' $'\201' $'\213'
Yes, this is a problem. The null match requires advancing through the
string by one character, instead of one byte. I'll fix it.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/