arabica/Utils/utf16beucs2codecvt.cpp

48 lines
1.7 KiB
C++
Raw Normal View History

2003-08-29 23:09:00 +02:00
//---------------------------------------------------------------------------
// $Id$
//---------------------------------------------------------------------------
2003-09-02 13:23:52 +02:00
#include "utf16beucs2codecvt.h"
#include "impl/ucs2_utf16.h"
2003-08-29 23:09:00 +02:00
//---------------------------------------------------------------------------
2003-09-02 13:23:52 +02:00
std::codecvt_base::result utf16beucs2codecvt::do_out(std::mbstate_t& /* state */,
2003-08-29 23:09:00 +02:00
const wchar_t* from,
const wchar_t* from_end,
const wchar_t*& from_next,
char* to,
char* to_limit,
char*& to_next) const
{
2003-09-02 13:23:52 +02:00
return ArabicaInternal::ucs2_2_utf16(true, from, from_end, from_next, to, to_limit, to_next);
2003-08-29 23:09:00 +02:00
} // do_out
2003-09-02 13:23:52 +02:00
std::codecvt_base::result utf16beucs2codecvt::do_in(std::mbstate_t& /* state */,
2003-08-29 23:09:00 +02:00
const char* from,
const char* from_end,
const char*& from_next,
wchar_t* to,
wchar_t* to_limit,
wchar_t*& to_next) const
{
2003-09-02 13:23:52 +02:00
return ArabicaInternal::utf16_2_ucs2(true, from, from_end, from_next, to, to_limit, to_next);
2003-08-29 23:09:00 +02:00
} // do_in
2003-09-02 13:23:52 +02:00
std::codecvt_base::result utf16beucs2codecvt::do_unshift(std::mbstate_t& /* state */,
2003-08-29 23:09:00 +02:00
char* to,
char* /* to_limit */,
char*& to_next) const
{
to_next = to;
return noconv;
} // do_unshift
2003-09-02 13:23:52 +02:00
int utf16beucs2codecvt::do_length(const std::mbstate_t&,
2003-08-29 23:09:00 +02:00
const char* from,
const char* end,
size_t max) const
{
2003-09-02 13:23:52 +02:00
return std::max<int>((end-from), max/2);
2003-08-29 23:09:00 +02:00
} // do_length
// end of file