2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: CodingSystem.C /main/2 1996/08/08 12:10:51 mgreess $ */
24 // Copyright (c) 1994 James Clark
25 // See the file COPYING for copying permission.
28 #pragma implementation
32 #include "CodingSystem.h"
33 #ifdef SP_SHORT_HEADERS
36 #include <strstream.h>
39 #include <sys/param.h>
42 namespace SP_NAMESPACE {
45 InputCodingSystem::~InputCodingSystem()
49 StringC InputCodingSystem::convertIn(const char *s) const
51 Decoder *decoder = makeDecoder();
53 str.resize(strlen(s));
54 str.resize(decoder->decode(&str[0], s, strlen(s), &s));
59 Boolean InputCodingSystem::isIdentity() const
64 OutputCodingSystem::~OutputCodingSystem()
68 unsigned OutputCodingSystem::fixedBytesPerChar() const
73 String<char> OutputCodingSystem::convertOut(const StringC &str) const
75 Encoder *encoder = makeEncoder();
76 strstreambuf stream(MAXPATHLEN);
78 encoder->output(copy.data(), copy.size(), &stream);
80 char *s = stream.str();
81 String<char> result(s, stream.out_waiting());
85 // Workaround lcc bug (3.1p2 with -O -XF).
86 String<char> temp(result);
93 Decoder::Decoder(unsigned minBytesPerChar)
94 : minBytesPerChar_(minBytesPerChar)
102 Boolean Decoder::convertOffset(unsigned long &) const
108 : unencodableHandler_(0)
116 void Encoder::output(Char *s, size_t n, streambuf *sp)
118 output((const Char *)s, n, sp);
121 void Encoder::startFile(streambuf *)