namespace std
{
- // XXX __enc_traits may need to move up the locale header heirarchy,
+ // XXX __enc_traits may need to move up the locale header hierarchy,
// depending on if ctype ends up using it.
#ifdef _GLIBCPP_USE_WCHAR_T
// Extensions to use icov for dealing with character encodings,
class __enc_traits
{
public:
- // Types:
- typedef iconv_t __conv_type;
- typedef mbstate_t __state_type;
+ // Types:
+ // NB: A conversion descriptor subsumes and enhances the
+ // functionality of a simple state type such as mbstate_t.
+ typedef iconv_t __desc_type;
protected:
// Data Members:
char __extc_enc[__max_size];
// Conversion descriptor between external encoding to internal encoding.
- __conv_type __in_desc;
+ __desc_type __in_desc;
// Conversion descriptor between internal encoding to external encoding.
- __conv_type __out_desc;
+ __desc_type __out_desc;
public:
__enc_traits() : __in_desc(0), __out_desc(0)
__enc_traits(const char* __int, const char* __ext)
: __in_desc(0), __out_desc(0)
{
- strcpy(__intc_enc, __int);
- strcpy(__extc_enc, __ext);
+ strncpy(__intc_enc, __int, __max_size);
+ strncpy(__extc_enc, __ext, __max_size);
+ }
+
+ // 21.1.2 traits typedefs
+ // p4
+ // typedef STATE_T state_type
+ // requires: state_type shall meet the requirements of
+ // CopyConstructible types (20.1.3)
+ __enc_traits(const __enc_traits& __obj)
+ {
+ strncpy(__intc_enc, __obj.__intc_enc, __max_size);
+ strncpy(__extc_enc, __obj.__extc_enc, __max_size);
}
~__enc_traits()
&& __out_desc != iconv_t(-1) && __in_desc != iconv_t(-1);
}
- const __conv_type*
+ const __desc_type*
_M_get_in_descriptor()
{ return &__in_desc; }
- const __conv_type*
+ const __desc_type*
_M_get_out_descriptor()
{ return &__out_desc; }
const char*
_M_get_external_enc()
{ return __extc_enc; }
-
- protected:
- // 21.1.2 traits typedefs
- // p4
- // typedef STATE_T state_type
- // requires: state_type shall meet the requirements of
- // CopyConstructible types (20.1.3)
- // XXX because of this, these might actually need to be filled out.
- __enc_traits(const __enc_traits&);
};
#endif //_GLIBCPP_USE_WCHAR_T
typedef _InternT intern_type;
typedef _ExternT extern_type;
typedef __enc_traits state_type;
- typedef __enc_traits::__conv_type __conv_type;
+ typedef __enc_traits::__desc_type __desc_type;
typedef __enc_traits __enc_type;
// Data Members:
result __ret = error;
if (__state._M_good())
{
- typedef state_type::__conv_type __conv_type;
- const __conv_type* __desc = __state._M_get_out_descriptor();
+ typedef state_type::__desc_type __desc_type;
+ const __desc_type* __desc = __state._M_get_out_descriptor();
const size_t __fmultiple = sizeof(intern_type) / sizeof(char);
size_t __flen = __fmultiple * (__from_end - __from);
const size_t __tmultiple = sizeof(extern_type) / sizeof(char);
result __ret = error;
if (__state._M_good())
{
- typedef state_type::__conv_type __conv_type;
- const __conv_type* __desc = __state._M_get_in_descriptor();
+ typedef state_type::__desc_type __desc_type;
+ const __desc_type* __desc = __state._M_get_in_descriptor();
const size_t __tmultiple = sizeof(intern_type) / sizeof(char);
size_t __tlen = __tmultiple * (__to_end - __to);
result __ret = error;
if (__state._M_good())
{
- typedef state_type::__conv_type __conv_type;
- const __conv_type* __desc = __state._M_get_in_descriptor();
+ typedef state_type::__desc_type __desc_type;
+ const __desc_type* __desc = __state._M_get_in_descriptor();
const size_t __fmultiple = sizeof(extern_type) / sizeof(char);
size_t __flen = __fmultiple * (__from_end - __from);
const size_t __tmultiple = sizeof(intern_type) / sizeof(char);
const unicode_codecvt& cvt = use_facet<unicode_codecvt>(loc);
// in
- unicode_codecvt::state_type state01("UNICODE", "ISO_8859-1");
+ unicode_codecvt::state_type state01("UNICODE", "ISO-8859-15");
initialize_state(state01);
result r1 = cvt.in(state01, e_lit, e_lit + size, efrom_next,
i_arr, i_arr + size, ito_next);
VERIFY( ito_next == i_arr + size );
// out
- unicode_codecvt::state_type state02("UNICODE", "ISO_8859-1");
+ unicode_codecvt::state_type state02("UNICODE", "ISO-8859-15");
initialize_state(state02);
result r2 = cvt.out(state02, i_lit, i_lit + size, ifrom_next,
e_arr, e_arr + size, eto_next);
// unshift
ext_traits::copy(e_arr, e_lit, size);
- unicode_codecvt::state_type state03("UNICODE", "ISO_8859-1");
+ unicode_codecvt::state_type state03("UNICODE", "ISO-8859-15");
initialize_state(state03);
result r3 = cvt.unshift(state03, e_arr, e_arr + size, eto_next);
VERIFY( r3 == codecvt_base::noconv );
VERIFY( !cvt.always_noconv() );
- unicode_codecvt::state_type state04("UNICODE", "ISO_8859-1");
+ unicode_codecvt::state_type state04("UNICODE", "ISO-8859-15");
initialize_state(state04);
int j = cvt.length(state03, e_lit, e_lit + size, 5);
VERIFY( j == 5 );