On 6/24/12 2:33 AM, Janis Papanagnou wrote:
>
>> From: [email protected]
>>
>> $ print $(( '_' )) $(( ':' ))
>> 95 58
>
> I wasn't aware that we can get the ordinal numbers of characters that way.
> Thanks!
>
> In cases where I am looking for the other way round, getting the character
> from its ordinal number, I intuitively always first try (though to no avail)
> printf "%c%c\n" 95 58
> As a workaround I still resort to
> $( echo 95P | dc )
> $( echo 58P | dc )
>
> Is there a simple *builtin* way for the other way round, get the character
> from its ordinal number? I seem to recall there was, but don't remember.
I'm chiming in a little late, here, but how about this:
$ printf "%x %x\n" $(('_')) $((':'))
5f 3a
$ print $'\x5f \x3a'
_ :
Or, there's always "man ascii" :).
But, another reason for bringing this up is that octal numbers used to work for
this purpose in $''. Now (ksh Version AJM 93u+ 2012-06-12), it appears that
3-digit octal numbers do not work...
$ printf "%o %o\n" $(('_')) $((':'))
137 72
$ printf $'\0137 \072' | cat -v
^K7 :
$ print $'\0100' # Should be @
0
$ print $'\077' # OK
?
Is this a bug?
Terrence Doyle
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users