Resend: implement _ismbcalpha, _ismbcalnum
Greg Turner
gmturner007 at ameritech.net
Sat Nov 16 09:21:28 CST 2002
On Saturday 16 November 2002 03:52 am, Dmitry Timoshkov wrote:
> "Greg Turner" <gmturner007 at ameritech.net> wrote:
> > So, I think, I
> > should #ifdef the byte-swapping based on the endianness of the
> > target platform (little-endian hosts byte-swap, big-endian hosts
> > don't).... does that sound right?
>
> I think there is no need for #ifdef's.
> Something like this should work:
>
> if (ch < 256)
> {
> mbch[0] = ch & 0xff;
> n_chars = 1;
> }
> else /* multibyte character */
> {
> mbch[0] = (ch >> 8) & 0xff;
> mbch[1] = ch & 0xff;
> n_chars = 2;
> }
Of course, you are right -- that looks great. Now I just have to figure
out that codepage thing, and I should be set.
An interesting side note: Microsoft claims that their implementations of
these functions are blindingly fast (they said something along the
lines that calling these is faster than "if (((0xXX <= ch) && (ch <=
0xYY)) || ((0xAA <= ch) && (ch <=0xBB)))"). I wonder if this means
they are using a lookup table in their implementation? Not planning to
implement any such thing myself, of course, but I did find it to be an
intrigueing statement.
--
gmt
"War is an ugly thing, but not the ugliest of things;
the decayed and degraded state of moral and patriotic
feeling which thinks that nothing is worth war is much
worse. A man who has nothing for which he is willing
to fight; nothing he cares about more than his own
personal safety; is a miserable creature who has no
chance of being free, unless made and kept so by the
exertions of better persons than himself."
-- John Stuart Mill
More information about the wine-devel
mailing list