1 // Copyright (c) 1994 James Clark
2 // See the file COPYING for copying permission.
9 #include "CodingSystem.h"
14 namespace SP_NAMESPACE {
17 InputCodingSystem::~InputCodingSystem()
21 StringC InputCodingSystem::convertIn(const char *s) const
23 Decoder *decoder = makeDecoder();
25 str.resize(strlen(s));
26 str.resize(decoder->decode(&str[0], s, strlen(s), &s));
31 Boolean InputCodingSystem::isIdentity() const
36 OutputCodingSystem::~OutputCodingSystem()
40 unsigned OutputCodingSystem::fixedBytesPerChar() const
45 String<char> OutputCodingSystem::convertOut(const StringC &str) const
47 Encoder *encoder = makeEncoder();
48 StrOutputByteStream stream;
49 encoder->output(str.data(), str.size(), &stream);
52 stream.extractString(result);
57 Decoder::Decoder(unsigned minBytesPerChar)
58 : minBytesPerChar_(minBytesPerChar)
66 Boolean Decoder::convertOffset(unsigned long &) const
79 Encoder::Handler::~Handler()
83 void Encoder::output(Char *s, size_t n, OutputByteStream *sp)
85 output((const Char *)s, n, sp);
88 void Encoder::startFile(OutputByteStream *)
92 void Encoder::handleUnencodable(Char, OutputByteStream *)
96 void Encoder::setUnencodableHandler(Handler *)
100 RecoveringEncoder::RecoveringEncoder()
101 : unencodableHandler_(0)
105 void RecoveringEncoder::handleUnencodable(Char c, OutputByteStream *sbufp)
107 if (unencodableHandler_)
108 unencodableHandler_->handleUnencodable(c, sbufp);
111 void RecoveringEncoder::setUnencodableHandler(Handler *handler)
113 unencodableHandler_ = handler;