3#if !defined (STLPORT) || !defined (_STLP_USE_NO_IOSTREAMS)
11# if !defined (STLPORT) || defined(_STLP_USE_NAMESPACES)
21#if defined (STLPORT) && defined (_STLP_NO_MEMBER_TEMPLATES)
26#if defined (STLPORT) && (defined (_STLP_NO_WCHAR_T) || !defined (_STLP_USE_EXCEPTIONS))
46# define __NO_THROW _STLP_NOTHROW
48# define __NO_THROW throw()
63 const char* ebegin,
const char* eend,
const char*& ecur,
64 char* ibegin,
char* iend,
char*& icur)
const __NO_THROW {
65 char *
state = (
char*)&mb;
69 while (ecur != eend) {
72 if (*ecur ==
'0' || *
state == 1) {
117 const char *efrom,
const char *eend,
size_t m)
const {
118 char *ibegin =
new char[
m];
119 const char *ecur = efrom;
122 do_in(tmp, efrom, eend, ecur, ibegin, ibegin +
m, icur);
156 const char* ebegin,
const char* eend,
const char*& ecur,
157 char* ibegin,
char* iend,
char*& icur)
const __NO_THROW {
159 char *
state = (
char*)&mb;
163 if (icur == iend)
return ok;
174 else if (*
state == 3) {
179 while (ecur != eend) {
182 if (*ecur ==
'0' || *
state == 1) {
237 const char *efrom,
const char *eend,
size_t m)
const {
238 const char *
state = (
const char*)&mb;
242 else if (*
state == 3)
245 char *ibegin =
new char[
m +
offset];
246 const char *ecur = efrom;
249 do_in(tmpState, efrom, eend, ecur, ibegin, ibegin +
m +
offset, icur);
269 return (
int)
min((
size_t)(ecur - efrom),
m);
291#if !defined (STLPORT) || !defined (_STLP_NO_MEMBER_TEMPLATES)
293 const char* fileName =
"test_file.txt";
298 for (
int i = 0;
i < 2048; ++
i) {
299 ostr <<
"0123456789";
316 int theoricalPos = 0;
350 int theoricalPos = 0;
366 theoricalTellg = theoricalPos;
370 if ((
int)istr.tellg() != theoricalTellg) {
384#if !defined (STLPORT) || !(defined (_STLP_NO_WCHAR_T) || !defined (_STLP_USE_EXCEPTIONS))
389 if (has_facet<cdecvt_type>(loc)) {
390 cdecvt_type
const& cdect = use_facet<cdecvt_type>(loc);
392 cdecvt_type::state_type
state;
393 memset(&
state, 0,
sizeof(cdecvt_type::state_type));
394 string from(
"abcdef");
395 const char* next_from;
399 to, to +
sizeof(to) /
sizeof(
wchar_t), next_to);
406 cdecvt_type::state_type
state;
407 memset(&
state, 0,
sizeof(cdecvt_type::state_type));
408 wstring
from(
L"abcdef");
409 const wchar_t* next_from;
413 to, to +
sizeof(to) /
sizeof(
char), next_to);
431#if !defined (STLPORT) || !(defined (_STLP_NO_WCHAR_T) || !defined (_STLP_USE_EXCEPTIONS))
436 if (has_facet<cdecvt_type>(loc)) {
437 cdecvt_type
const& cdect = use_facet<cdecvt_type>(loc);
439 cdecvt_type::state_type
state;
440 memset(&
state, 0,
sizeof(cdecvt_type::state_type));
441 string from(
"abcdef");
455#if !defined (STLPORT) || !(defined (_STLP_NO_WCHAR_T) || !defined (_STLP_USE_EXCEPTIONS))
465 const extern_type* last1,
const extern_type*& next1,
466 intern_type* first2, intern_type* last2,
467 intern_type*& next2)
const {
468 for ( next1 = first1, next2 = first2; next1 < last1; next1 += 2 ) {
469 if ( (last1 - next1) < 2 || (last2 - next2) < 1 )
471 *next2++ = (intern_type)((*(next1 + 1) << 8) | (*next1 & 255));
486#if !defined (STLPORT) || !(defined (_STLP_NO_WCHAR_T) || !defined (_STLP_USE_EXCEPTIONS))
489 const wchar_t buf[] =
L" ";
490 for (
int i = 0;
i < 4098; ++
i ) {
509#if !defined (STLPORT) || (!defined (_STLP_NO_WCHAR_T) && defined (_STLP_USE_EXCEPTIONS))
516 const char *from_next;
528 const string cp936_str =
"\xd6\xd0\xb9\xfa\xc9\xe7\xbb\xe1\xbf\xc6\xd1\xa7\xd4\xba\xb7\xa2\xb2\xbc\x32\x30\x30\x38\xc4\xea\xa1\xb6\xbe\xad\xbc\xc3\xc0\xb6\xc6\xa4\xca\xe9\xa1\xb7\xd6\xb8\xb3\xf6\xa3\xac\x32\x30\x30\x37\xc4\xea\xd6\xd0\xb9\xfa\xbe\xad\xbc\xc3\xd4\xf6\xb3\xa4\xd3\xc9\xc6\xab\xbf\xec\xd7\xaa\xcf\xf2\xb9\xfd\xc8\xc8\xb5\xc4\xc7\xf7\xca\xc6\xc3\xf7\xcf\xd4\xd4\xa4\xbc\xc6\xc8\xab\xc4\xea\x47\x44\x50\xd4\xf6\xcb\xd9\xbd\xab\xb4\xef\x31\x31\x2e\x36\x25\xa1\xa3";
539 int len =
cvt.length(
state, cp936_str.data(), cp936_str.data() + cp936_str.size(),
sizeof(wbuf) /
sizeof(
wchar_t));
542 const char *from_next;
544 res =
cvt.in(
state, cp936_str.data(), cp936_str.data() + cp936_str.size(), from_next,
545 wbuf, wbuf +
sizeof(wbuf) /
sizeof(
wchar_t), to_next);
547 CPPUNIT_ASSERT( from_next == cp936_str.data() + cp936_str.size() );
548 cp936_wstr.assign(wbuf, to_next);
552 const wchar_t *from_next;
555 res =
cvt.out(
state, cp936_wstr.data(), cp936_wstr.data() + cp936_wstr.size(), from_next,
563 CPPUNIT_MESSAGE(
"Not enough platform localization support to check 936 code page encoding.");
567 const string utf8_str =
"\xe4\xb8\xad\xe5\x9b\xbd\xe7\xa4\xbe\xe4\xbc\x9a\xe7\xa7\x91\xe5\xad\xa6\xe9\x99\xa2\xe5\x8f\x91\xe5\xb8\x83\x32\x30\x30\x38\xe5\xb9\xb4\xe3\x80\x8a\xe7\xbb\x8f\xe6\xb5\x8e\xe8\x93\x9d\xe7\x9a\xae\xe4\xb9\xa6\xe3\x80\x8b\xe6\x8c\x87\xe5\x87\xba\xef\xbc\x8c\x32\x30\x30\x37\xe5\xb9\xb4\xe4\xb8\xad\xe5\x9b\xbd\xe7\xbb\x8f\xe6\xb5\x8e\xe5\xa2\x9e\xe9\x95\xbf\xe7\x94\xb1\xe5\x81\x8f\xe5\xbf\xab\xe8\xbd\xac\xe5\x90\x91\xe8\xbf\x87\xe7\x83\xad\xe7\x9a\x84\xe8\xb6\x8b\xe5\x8a\xbf\xe6\x98\x8e\xe6\x98\xbe\xe9\xa2\x84\xe8\xae\xa1\xe5\x85\xa8\xe5\xb9\xb4\x47\x44\x50\xe5\xa2\x9e\xe9\x80\x9f\xe5\xb0\x86\xe8\xbe\xbe\x31\x31\x2e\x36\x25\xe3\x80\x82";
579 int len =
cvt.length(
state, utf8_str.data(), utf8_str.data() + utf8_str.size(),
sizeof(wbuf) /
sizeof(
wchar_t));
582 const char *from_next;
584 res =
cvt.in(
state, utf8_str.data(), utf8_str.data() + utf8_str.size(), from_next,
585 wbuf, wbuf +
sizeof(wbuf) /
sizeof(
wchar_t), to_next);
588 utf8_wstr.assign(wbuf, to_next);
592 const char*
from = utf8_str.data();
593 const char* from_end =
from + utf8_str.size();
594 from_next = utf8_str.data();
599 &wc, &wc + 1, to_next);
609 if (from_next ==
from)
627 const wchar_t *from_next;
630 res =
cvt.out(
state, utf8_wstr.data(), utf8_wstr.data() + utf8_wstr.size(), from_next,
638 const string bad_utf8_str(
"\xdf\xdf\xdf\xdf\xdf");
640 const char *from_next;
642 res =
cvt.in(
state, bad_utf8_str.data(), bad_utf8_str.data() + bad_utf8_str.size(), from_next,
643 &wc, &wc + 1, to_next);
649 CPPUNIT_MESSAGE(
"Not enough platform localization support to check UTF8 encoding.");
basic_ofstream< char, char_traits< char > > ofstream
basic_ifstream< char, char_traits< char > > ifstream
_STLP_MOVE_TO_PRIV_NAMESPACE locale::id & _GetFacetId(const _Facet *)
void imbue_while_reading()
CPPUNIT_TEST(in_out_test)
CPPUNIT_TEST(special_encodings)
CPPUNIT_TEST(length_test)
CPPUNIT_TEST(imbue_while_reading)
CPPUNIT_TEST_SUITE(CodecvtTest)
CPPUNIT_TEST(variable_encoding)
locale imbue(const locale &)
_Self & seekg(pos_type __pos)
static _STLP_STATIC_DECLSPEC locale::id id
static const locale &_STLP_CALL classic()
virtual result do_in(state_type &, const extern_type *first1, const extern_type *last1, const extern_type *&next1, intern_type *first2, intern_type *last2, intern_type *&next2) const
virtual bool do_always_noconv() const __NO_THROW
virtual int do_max_length() const __NO_THROW
virtual int do_encoding() const __NO_THROW
std::codecvt< wchar_t, char, mbstate_t > my_codecvt_base
#define CPPUNIT_MESSAGE(m)
#define CPPUNIT_TEST_SUITE_REGISTRATION(X)
#define CPPUNIT_ASSERT(X)
static char * cvt(double arg, int ndigits, int *decpt, int *sign, char *buf, int eflag)
GLdouble GLdouble GLdouble r
GLenum GLuint GLenum GLsizei const GLchar * buf
GLuint GLsizei GLsizei * length
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
virtual base::result do_in(mbstate_t &mb, const char *ebegin, const char *eend, const char *&ecur, char *ibegin, char *iend, char *&icur) const __NO_THROW
virtual bool do_always_noconv() const __NO_THROW
virtual int do_max_length() const __NO_THROW
virtual int do_encoding() const __NO_THROW
virtual int do_length(mbstate_t &state, const char *efrom, const char *eend, size_t m) const
codecvt< char, char, mbstate_t > base
eater_codecvt(size_t refs=0)
virtual int do_max_length() const __NO_THROW
virtual int do_encoding() const __NO_THROW
virtual int do_length(mbstate_t &mb, const char *efrom, const char *eend, size_t m) const
codecvt< char, char, mbstate_t > base
virtual bool do_always_noconv() const __NO_THROW
generator_codecvt(size_t refs=0)
virtual base::result do_in(mbstate_t &mb, const char *ebegin, const char *eend, const char *&ecur, char *ibegin, char *iend, char *&icur) const __NO_THROW