EUCJPCodingSystem.cxx revision 7c478bd95313f5f23a4c958a745db2134aa03244
// Copyright (c) 1994 James Clark
// See the file COPYING for copying permission.
#pragma ident "%Z%%M% %I% %E% SMI"
#include "splib.h"
#ifdef SP_MULTI_BYTE
#include "EUCJPCodingSystem.h"
#ifdef SP_NAMESPACE
namespace SP_NAMESPACE {
#endif
class EUCJPDecoder : public Decoder {
public:
EUCJPDecoder() { }
private:
};
class EUCJPEncoder : public Encoder {
public:
EUCJPEncoder() { }
}
};
{
return new EUCJPDecoder;
}
{
return new EUCJPEncoder;
}
{
const unsigned char *us = (const unsigned char *)s;
while (slen > 0) {
if (!(*us & 0x80)) {
// G0
slen--;
}
else if (*us == 0x8e) {
// G2
if (slen < 2)
break;
slen -= 2;
++us;
}
else if (*us == 0x8f) {
// G3
if (slen < 3)
break;
slen -= 3;
++us;
n |= (*us++ & ~0x80);
*to++ = n;
}
else {
// G1
if (slen < 2)
break;
slen -= 2;
unsigned short n = *us++ << 8;
n |= (*us++ | 0x80);
*to++ = n;
}
}
}
{
for (; n > 0; s++, n--) {
Char c = *s;
unsigned short mask = (unsigned short)(c & 0x8080);
if (mask == 0)
else if (mask == 0x8080) {
}
else if (mask == 0x0080) {
}
else {
// mask == 0x8000
}
}
}
#ifdef SP_NAMESPACE
}
#endif
#else /* not SP_MULTI_BYTE */
#ifndef __GNUG__
static char non_empty_translation_unit; // sigh
#endif
#endif /* not SP_MULTI_BYTE */