Regina 7.3 Calculation Engine
|
An output stream buffer that translates between character encodings. More...
#include <utilities/i18nutils.h>
Public Member Functions | |
IConvStreamBuffer () | |
Creates a new stream buffer. More... | |
~IConvStreamBuffer () override | |
Destroys this stream buffer. More... | |
IConvStreamBuffer * | open (std::ostream &dest, const char *srcCode, const char *destCode) |
Opens a new stream buffer that wraps around the given output stream. More... | |
IConvStreamBuffer * | close () noexcept |
Closes this stream buffer. More... | |
int_type | overflow (int_type c) override |
Sends buffered data to the destination output stream, converting between character sets en route. More... | |
int_type | underflow () override |
Simply returns EOF (since this is not an input stream). More... | |
int | sync () override |
Flushes all output buffers. More... | |
IConvStreamBuffer (const IConvStreamBuffer &)=delete | |
IConvStreamBuffer & | operator= (const IConvStreamBuffer &)=delete |
An output stream buffer that translates between character encodings.
The iconv library is used to do the real work.
Users should not normally instantiate this class directly; instead see IConvStream for a higher-level interface to character conversion.
This class will still work if iconv is not supported on the build machine, though in this case it will simply pass data through without performing any translations.
|
inline |
Creates a new stream buffer.
|
inlineoverride |
Destroys this stream buffer.
This stream buffer will be closed, but the destination output stream will not be.
|
noexcept |
Closes this stream buffer.
null
on error. IConvStreamBuffer * regina::i18n::IConvStreamBuffer::open | ( | std::ostream & | dest, |
const char * | srcCode, | ||
const char * | destCode | ||
) |
Opens a new stream buffer that wraps around the given output stream.
If this stream buffer is already open, it will be closed and then reopened with the given parameters.
Any data that is sent to this stream buffer will be translated from srcCode to destCode and passed on to the given output stream.
If the given encodings are invalid, this stream will still forward data to the given output stream but no conversion will take place.
See the iconv documentation for information on what encodings are supported. For the GNU C library implementation, valid encodings can be found by running iconv --list
.
dest | the destination output stream. |
srcCode | the character encoding for data that is to be written into this stream buffer. |
destCode | the character encoding for the translated data that will subsequently be written to the destination output stream. |
null
on error.
|
override |
Sends buffered data to the destination output stream, converting between character sets en route.
The buffer will be flushed as far as possible, and any invalid characters will be replaced with one or more question marks. If the buffer ends in an incomplete multibyte character, this incomplete character will be held back (since it presumably needs to be combined with later input).
c | an extra character to send that did not fit in the internal buffer, or EOF if we simply wish to flush the buffer. |
|
override |
Flushes all output buffers.
The buffers for both this stream and the destination output stream will be flushed.
|
inlineoverride |
Simply returns EOF (since this is not an input stream).