William James wrote:
> 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
> >
> > 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

Umpf... it seems the code uses |char| where it should use |wchar_t| to
handle locale-specific character values > 127 (AFAIK using |wchar_t| is
the best choice in this case... David ?).

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz at nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)

Reply via email to