fixed parameter order in iconv_open()
This commit is contained in:
parent
c0581902ae
commit
920478dfa4
@ -47,7 +47,7 @@ int main(int argc, char * argv[])
|
||||
cout << "Size: " << ucs_str->size() << endl;
|
||||
for (int i = 0; i < ucs_str->size(); i++)
|
||||
{
|
||||
cout << (*ucs_str)[i] << ": '" << (char) (*ucs_str)[i] << "'" << endl;
|
||||
cout << dec << (*ucs_str)[i] << " (0x" << hex << (*ucs_str)[i] << "): '" << (char) ((*ucs_str)[i] & 0xFF) << "'" << endl;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
10
serialize.cc
10
serialize.cc
@ -15,10 +15,16 @@ refptr< vector<unichar_t> > deserialize(const char * encoding, istream & in)
|
||||
unichar_t * outbuf = new unichar_t[buf_size];
|
||||
char * outbuf_ptr;
|
||||
size_t chars_converted, inbytesleft = 0, outbytesleft;
|
||||
const char * to_encoding;
|
||||
refptr< vector<unichar_t> > ucs = new vector<unichar_t>();
|
||||
|
||||
cout << "encoding: " << encoding << endl;
|
||||
iconv_t cd = iconv_open(encoding, "UCS-4");
|
||||
{
|
||||
uint32_t endianness_test = 1u;
|
||||
uint8_t * p = (uint8_t *) &endianness_test;
|
||||
to_encoding = (*p == 1) ? "UCS-4LE" : "UCS-4BE";
|
||||
}
|
||||
|
||||
iconv_t cd = iconv_open(/* to */ to_encoding, /* from */ encoding);
|
||||
if (cd == (iconv_t) -1)
|
||||
{
|
||||
cerr << "iconv_open() error" << endl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user