arabica/Utils/utf16utf8_codecvt.h

62 lines
1.8 KiB
C
Raw Normal View History

2002-06-21 13:16:28 +02:00
#ifndef utf16utf8_codecvtH
#define utf16utf8_codecvtH
//---------------------------------------------------------------------------
// class utf16tf8_codecvt
// 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$
//---------------------------------------------------------------------------
#include <locale>
#ifdef _MSC_VER
namespace std {
typedef ::mbstate_t mbstate_t;
}
#endif
class utf16utf8_codecvt : public std::codecvt<wchar_t, char, std::mbstate_t>
{
protected:
virtual ~utf16utf8_codecvt();
virtual result do_out(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;
virtual result do_in(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;
virtual result do_unshift(std::mbstate_t&,
char*,
char*,
char*&) const;
virtual int do_encoding() const throw();
virtual bool do_always_noconv() const throw();
virtual int do_length(const std::mbstate_t&,
const char* from,
const char* end,
size_t max) const;
virtual int do_max_length() const throw();
}; // class utf16utf8_codecvt
#endif