arabica/include/convert/utf16utf8codecvt.hpp

73 lines
2.1 KiB
C++
Raw Normal View History

2003-08-29 23:09:00 +02:00
#ifndef ARABICA_UTF16UTF8_CODECVT_H
#define ARABICA_UTF16UTF8_CODECVT_H
2002-06-21 13:16:28 +02:00
//---------------------------------------------------------------------------
2003-08-29 23:09:00 +02:00
// class utf16utf8codecvt
2002-06-21 13:16:28 +02:00
// This facet converts from Unicode (UCS-2) wchar_ts to
// char using the UTF-8 encoding.
//
// For the full guff on codecvts see section 22.2.1.5 of
// The C++ Standard (ISO/IEC 14882 to be pedantic).
//
// I got my information about UTF-8 from RFC 2044.
//
// $Id$
//---------------------------------------------------------------------------
2007-09-05 00:55:47 +02:00
#include <SAX/ArabicaConfig.hpp>
#include <Arabica/mbstate.hpp>
2002-06-21 13:16:28 +02:00
#include <locale>
#ifndef ARABICA_NO_CODECVT_SPECIALISATIONS
#include <convert/impl/codecvt_specialisations.hpp>
#endif
2003-09-10 17:15:55 +02:00
2003-09-13 01:15:14 +02:00
namespace Arabica
{
namespace convert
{
2003-08-29 23:09:00 +02:00
class utf16utf8codecvt : public std::codecvt<char, wchar_t, std::mbstate_t>
2002-06-21 13:16:28 +02:00
{
protected:
2003-09-13 01:15:14 +02:00
typedef std::codecvt_base::result result;
2003-08-29 23:09:00 +02:00
virtual ~utf16utf8codecvt() { }
2002-06-21 13:16:28 +02:00
virtual result do_out(std::mbstate_t&,
const char* from,
const char* from_end,
const char*& from_next,
wchar_t* to,
wchar_t* to_limit,
wchar_t*& to_next) const;
2003-08-29 23:09:00 +02:00
virtual result do_in(std::mbstate_t&,
const wchar_t* from,
const wchar_t* from_end,
const wchar_t*& from_next,
char* to,
char* to_limit,
char*& to_next) const;
2002-06-21 13:16:28 +02:00
virtual result do_unshift(std::mbstate_t&,
2003-08-29 23:09:00 +02:00
wchar_t*,
wchar_t*,
wchar_t*&) const;
2002-06-21 13:16:28 +02:00
2003-08-29 23:09:00 +02:00
virtual int do_encoding() const throw() { return 0; }
2002-06-21 13:16:28 +02:00
2003-08-29 23:09:00 +02:00
virtual bool do_always_noconv() const throw() { return false; }
2002-06-21 13:16:28 +02:00
virtual int do_length(const std::mbstate_t&,
2003-08-29 23:09:00 +02:00
const wchar_t* from,
const wchar_t* end,
2002-06-21 13:16:28 +02:00
size_t max) const;
2003-08-29 23:09:00 +02:00
virtual int do_max_length() const throw() { return 1; }
}; // class utf16utf8codecvt
2002-06-21 13:16:28 +02:00
2003-09-11 16:05:18 +02:00
} // namespace convert
} // namespace Arabica
2003-09-11 16:26:26 +02:00
2002-06-21 13:16:28 +02:00
#endif