mirror of
https://github.com/unicode-org/icu.git
synced 2025-04-14 17:24:01 +00:00
ICU-5882 revert changes: ticket 5869 needs to be either fixed or rolled back, and the original test code in csdetest.cpp helps expose 5869's problem
X-SVN-Rev: 22602
This commit is contained in:
parent
a516a115d0
commit
172c5af054
1 changed files with 5 additions and 15 deletions
|
@ -108,26 +108,16 @@ static UnicodeString *split(const UnicodeString &src, UChar ch, int32_t &splits)
|
|||
|
||||
static char *extractBytes(const UnicodeString &source, const char *codepage, int32_t &length)
|
||||
{
|
||||
UErrorCode status = U_ZERO_ERROR;
|
||||
UConverter *cnv = ucnv_open(codepage, &status);
|
||||
int32_t sLength = source.length();
|
||||
char *bytes = NULL;
|
||||
|
||||
length = source.extract(NULL, 0, cnv, status);
|
||||
length = source.extract(0, sLength, NULL, codepage);
|
||||
|
||||
if (status == U_BUFFER_OVERFLOW_ERROR) {
|
||||
status = U_ZERO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (U_SUCCESS(status) && length > 0) {
|
||||
int32_t capacity = length + ucnv_getMinCharSize(cnv);
|
||||
|
||||
bytes = NEW_ARRAY(char, capacity);
|
||||
source.extract(bytes, capacity, cnv, status);
|
||||
if (length > 0) {
|
||||
bytes = NEW_ARRAY(char, length + 1);
|
||||
source.extract(0, sLength, bytes, codepage);
|
||||
}
|
||||
|
||||
ucnv_close(cnv);
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue