esc sequences within strings - awk
This is a discussion on esc sequences within strings - awk ; Hi,
This line of awk code:
print "\x1b --- \x1bA \x1bB \x1bC \x1bD \x1bE \x1bF --- \x1bG" > "dr-tmpname"
results in (displayed by elvis):
offset 0 1 2 3 4 5 6 7 8 9 a b c d e ...
-
esc sequences within strings
Hi,
This line of awk code:
print "\x1b --- \x1bA \x1bB \x1bC \x1bD \x1bE \x1bF --- \x1bG" > "dr-tmpname"
results in (displayed by elvis):
offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00000000 <1b>20 2d 2d 2d 20 ba 20 bb 20 bc 20 bd 20 be 20 . --- º » ? ? ?
00000010 bf 20 2d 2d 2d 20 1b 47 0a ¿ --- .G.
~
As you can see,
"\1b" yields ESC,
"\1bG" yields ESC G,
but
"\x1bA" to "\x1bF" result in hex 'ba' to hex 'bf',
NOT ESC A .. ESC F (as I expected). That puzzles me, as
I can't put ESC E into the file.
Would you please help me out?
thanks!
awk -W version shows:
GNU Awk 3.1.5
Copyright (C) 1989, 1991-2005 Free Software Foundation.
Regards siggi
--
s.e.
---
-
Re: esc sequences within strings
In article
<45219045$0$18490$9b4e6d93@newsspool3.arcor-online.net>,
siegfried eckloff <kobolomombo@tetumu.de> wrote:
> Hi,
>
> This line of awk code:
>
> print "\x1b --- \x1bA \x1bB \x1bC \x1bD \x1bE \x1bF --- \x1bG" > "dr-tmpname"
>
> results in (displayed by elvis):
>
> offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
> 00000000 <1b>20 2d 2d 2d 20 ba 20 bb 20 bc 20 bd 20 be 20 . --- º » ? ? ?
> 00000010 bf 20 2d 2d 2d 20 1b 47 0a ¿ --- .G.
> ~
>
> As you can see,
> "\1b" yields ESC,
> "\1bG" yields ESC G,
>
> but
>
> "\x1bA" to "\x1bF" result in hex 'ba' to hex 'bf',
> NOT ESC A .. ESC F (as I expected). That puzzles me, as
> I can't put ESC E into the file.
> Would you please help me out?
>
> thanks!
>
> awk -W version shows:
>
> GNU Awk 3.1.5
> Copyright (C) 1989, 1991-2005 Free Software Foundation.
>
>
> Regards siggi
looks like a bug to me.
As a workaround you could try
print "\x1b" "A \x1b" "B \x1b" "C \x1b" "D \x1b" "E \x1b" "F"
You could also try
esc = 27
printf("%cA %cB %cC %cD %cE %cF\n",
esc, esc, esc, esc, esc, esc)
You could also try
print "\033A \033B \033C \033D \033E \033F"
Bob Harris
-
Re: esc sequences within strings
Bob Harris wrote:
> In article
> <45219045$0$18490$9b4e6d93@newsspool3.arcor-online.net>,
> siegfried eckloff <kobolomombo@tetumu.de> wrote:
>
>> Hi,
>>
>> This line of awk code:
>>
>> print "\x1b --- \x1bA \x1bB \x1bC \x1bD \x1bE \x1bF --- \x1bG" >
>> "dr-tmpname"
>>
>> results in (displayed by elvis):
>>
>> offset 0 1 2 3 4 5 6 7 8 9 a b c d e f
>> 0123456789abcdef
>> 00000000 <1b>20 2d 2d 2d 20 ba 20 bb 20 bc 20 bd 20 be 20 . --- º
>> » ? ? ?
>> 00000010 bf 20 2d 2d 2d 20 1b 47 0a ¿ ---
>> .G. ~
>>
>> As you can see,
>> "\1b" yields ESC,
>> "\1bG" yields ESC G,
>>
>> but
>>
>> "\x1bA" to "\x1bF" result in hex 'ba' to hex 'bf',
>> NOT ESC A .. ESC F (as I expected). That puzzles me, as
>> I can't put ESC E into the file.
>> Would you please help me out?
>>
>> thanks!
>>
>> awk -W version shows:
>>
>> GNU Awk 3.1.5
>> Copyright (C) 1989, 1991-2005 Free Software Foundation.
>>
>>
>> Regards siggi
>
> looks like a bug to me.
such things happen...
> As a workaround you could try
>
> print "\x1b" "A \x1b" "B \x1b" "C \x1b" "D \x1b" "E \x1b" "F"
that doesn't work, too: there's an additional blank in between ESC and the letter:
print "\x1b", "E" > "dr-tmpname"
results in:
offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00000000 <1b>20 45 0a . E.
~
whereas both of these:
> You could also try
>
> esc = 27
> printf("%cA %cB %cC %cD %cE %cF\n",
> esc, esc, esc, esc, esc, esc)
>
> You could also try
>
> print "\033A \033B \033C \033D \033E \033F"
work well:
offset 0 1 2 3 4 5 6 7 8 9 a b c d e f 0123456789abcdef
00000000 <1b>45 0a .E.
~
thank you!
siggi
--
s.e.
---
Similar Threads
-
By Application Development in forum Python
Replies: 5
Last Post: 12-02-2007, 06:39 AM
-
By Application Development in forum Python
Replies: 4
Last Post: 08-23-2007, 05:20 AM
-
By Application Development in forum Home Automation
Replies: 0
Last Post: 05-04-2007, 06:48 AM
-
By Application Development in forum Compilers
Replies: 1
Last Post: 04-18-2007, 12:51 PM
-
By Application Development in forum Perl
Replies: 2
Last Post: 05-06-2005, 09:26 PM