This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: Locale codecvt facet doesn't seem to return 'partial'
Of course, in that case, please provide a *self contained* testcase: to
say one, in order to understand whether something is really going wrong
we *must* know which specific locale you are using.
Yep.
For the record, this is what I was using.
#include <locale>
int foo1()
{
using namespace std;
typedef codecvt_base::result Result;
typedef string::traits_type::state_type State;
typedef codecvt<wstring::value_type, string::value_type, State>
Converter;
string from("\xC2\xA1Hasta ma\xC3\xB1\x61na!");
string from2("\xC2\xA1Hasta ma\xC3");
string from3("¡Hasta mañana!");
static wchar_t to[256];
static wchar_t to2[256];
static wchar_t to3[256];
const string::value_type *me = 0;
wstring::value_type *we = 0;
State q;
Result status;
// locale loc = locale("es_US.UTF-8");
locale loc = locale("es_CR.utf8");
locale::global(loc);
const Converter& cvt = use_facet<Converter>(loc);
memset(&q, 0, sizeof(q));
size_t s1 = from.size(); // gdb still cannot eval string.size()
status = cvt.in(q, from.data(), from.data() + s1, me,
to, to + sizeof(to)/sizeof(to[0]), we);
memset(&q, 0, sizeof(q));
size_t s2 = from2.size();
status = cvt.in(q, from2.data(), from2.data() + s2, me,
to2, to2 + sizeof(to2)/sizeof(to2[0]), we);
memset(&q, 0, sizeof(q));
size_t s3 = from3.size();
status = cvt.in(q, from3.data(), from3.data() + s3, me,
to3, to3 + sizeof(to3)/sizeof(to3[0]), we);
return 0;
}
int main()
{
foo1();
}