Fix narrow/wide encoding issues found through new test suite additions

darcs-hash:20070923210007-75c98-9ffee3b8f1ce24e1d6f178baa1f2ef52d70ee38b.gz
This commit is contained in:
liljencrantz 2007-09-24 07:00:07 +10:00
parent 5e2e9e2b9b
commit 449a75756d

View file

@ -263,6 +263,18 @@ wchar_t *str2wcs_internal( const char *in, wchar_t *out )
{
res = mbrtowc( &out[out_pos], &in[in_pos], len-in_pos, &state );
if( ( out[out_pos] >= ENCODE_DIRECT_BASE) &&
( out[out_pos] < ENCODE_DIRECT_BASE+256) ||
out[out_pos] == INTERNAL_SEPARATOR )
{
out[out_pos] = ENCODE_DIRECT_BASE + (unsigned char)in[in_pos];
in_pos++;
memset( &state, 0, sizeof(state) );
out_pos++;
}
else
{
switch( res )
{
case (size_t)(-2):
@ -287,6 +299,8 @@ wchar_t *str2wcs_internal( const char *in, wchar_t *out )
}
out_pos++;
}
}
out[out_pos] = 0;
return out;