While investigating why our UTF-16 files are broken (with a smaller output buffer),
I noticed that "state" was never set, but as expected this doesn't help at all: we just can't use iconv() this way, I'll open a bug for this. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@19844 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2006, Haiku, Inc. All Rights Reserved.
|
* Copyright 2003-2007, Haiku, Inc. All Rights Reserved.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Authors:
|
* Authors:
|
||||||
@@ -40,17 +40,24 @@ convert_encoding(const char* from, const char* to, const char* src,
|
|||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: this doesn't work, as the state is reset every time!
|
||||||
iconv_t conversion = iconv_open(to, from);
|
iconv_t conversion = iconv_open(to, from);
|
||||||
if (conversion == (iconv_t)-1) {
|
if (conversion == (iconv_t)-1) {
|
||||||
DEBPRINT(("iconv_open failed\n"));
|
DEBPRINT(("iconv_open failed\n"));
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
}
|
}
|
||||||
if (state == NULL || *state == 0)
|
|
||||||
iconv(conversion, 0, 0, 0, 0);
|
size_t outputLeft = *dstLen;
|
||||||
|
|
||||||
|
if (state == NULL || *state == 0) {
|
||||||
|
if (state != NULL)
|
||||||
|
*state = 1;
|
||||||
|
|
||||||
|
iconv(conversion, NULL, NULL, &dst, &outputLeft);
|
||||||
|
}
|
||||||
|
|
||||||
char** inputBuffer = const_cast<char**>(&src);
|
char** inputBuffer = const_cast<char**>(&src);
|
||||||
size_t inputLeft = *srcLen;
|
size_t inputLeft = *srcLen;
|
||||||
size_t outputLeft = *dstLen;
|
|
||||||
do {
|
do {
|
||||||
size_t nonReversibleConversions = iconv(conversion, inputBuffer,
|
size_t nonReversibleConversions = iconv(conversion, inputBuffer,
|
||||||
&inputLeft, &dst, &outputLeft);
|
&inputLeft, &dst, &outputLeft);
|
||||||
|
|||||||
Reference in New Issue
Block a user