[ksh93-integration-discuss] Character to character integer value?

William James williamjamesgnusolaris at gmail.com
Fri Jan 26 12:28:49 PST 2007


On 1/26/07, David Korn <dgk at research.att.com> wrote:
>
> > How can I convert a character like ù (small u, grave accent) to the
> > integer character value of the current locale, i.e. per
> > http://saftsack.fs.uni-bayreuth.de/html/HTML_2.0/iso8859-1.html ù is
> > 249
> >
> > Cheers,
> > William
> > --
> >     @,,@   William James
> >    (\--/)  williamjamesgnusolaris at gmail.com
> >   (.>__<.) GNU/Solaris hacker
>
> ksh93 supports character constants in integer expressions, thus
>         $(('`'))
> will expand to the character value for grave and $(('u')) will
> give the character value for small u.  However, character values
> can be signed so that
>         $(('ù'))
> expands to a signed number.  However, you can do
>         printf "%u\n" $(('ù' &0xff ))
> to get the unsigned value.

That works in the en_US.iso885915 locale but in en_US.utf8 it fails:
$ printf "%u\n" $(('1'))
49
$ printf "%u\n" $(('ù'))
ksh: 'ù': arithmetic syntax error

Cheers,
William
-- 
    @,,@   William James
   (\--/)  williamjamesgnusolaris at gmail.com
  (.>__<.) GNU/Solaris hacker



More information about the ksh93-integration-discuss mailing list