[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: bash prints numeric values of unicode characters instead of their UT
Re: bash prints numeric values of unicode characters instead of their UTF8 representations
Wed, 3 Feb 2016 16:13:49 -0500
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.5.1
On 2/3/16 3:20 PM, Yuri wrote:
> On 01/31/2016 13:41, Yuri wrote:
>> I have this line in ~/.bashrc:
>> PS1=$'\\[\e[0;38;5;202m\\]\u2514\u2023\\[\e[0m\\] '
> This link
> says: "Since bash 4.2, you can use \u followed by 4 hexadecimal digits in a
> $'…' string".
> My bash-4.3.42 misinterprets \u as the user name instead.
> So what could be wrong? Is \u supposed to be a user name or a unicode
> codepoint hexadecimal prefix?
Sigh. You are mixing two things that perform backslash-escape character
processing. If there is no character corresponding to a particular unicode
value in the current character set, the escape sequence is left unchanged.
So you get through a round of expansion with the $'...' processing, and the
\u2514 is preserved in the result. The PS1 expansion code sees the \u and
turns it into the current username.
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU address@hidden http://cnswww.cns.cwru.edu/~chet/