1999-08-16 21:50:52 +00:00
|
|
|
#define EXTENDED_FUNCTIONALITY
|
|
|
|
#include "cpputils.h"
|
|
|
|
#include "cstring.h"
|
1999-12-28 23:39:02 +00:00
|
|
|
#include "unicode/ustring.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
1999-12-09 23:27:55 +00:00
|
|
|
/**********************************************************************
|
|
|
|
* Copyright (C) 1999, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************/
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
/******************************************************
|
|
|
|
* Simple utility to set output buffer parameters
|
|
|
|
******************************************************/
|
|
|
|
void T_fillOutputParams(const UnicodeString* temp,
|
|
|
|
UChar* result,
|
|
|
|
const int32_t resultLength,
|
|
|
|
int32_t* resultLengthOut,
|
|
|
|
UErrorCode* status)
|
|
|
|
{
|
|
|
|
|
1999-12-08 02:11:04 +00:00
|
|
|
const int32_t actual = temp->length();
|
1999-08-16 21:50:52 +00:00
|
|
|
const bool_t overflowed = actual >= resultLength;
|
1999-12-28 23:39:02 +00:00
|
|
|
const int32_t returnedSize = uprv_min(actual, resultLength-1);
|
1999-12-08 02:11:04 +00:00
|
|
|
if ((temp->length() < resultLength) && (result != temp->getUChars()) && (returnedSize > 0)) {
|
1999-08-16 21:50:52 +00:00
|
|
|
u_strcpy(result, temp->getUChars());
|
|
|
|
}
|
|
|
|
|
|
|
|
if (resultLength > 0) {
|
|
|
|
result[returnedSize] = 0;
|
|
|
|
}
|
|
|
|
if (resultLengthOut) {
|
|
|
|
*resultLengthOut = actual;
|
1999-10-18 22:48:32 +00:00
|
|
|
if (U_SUCCESS(*status) && overflowed) {
|
1999-10-07 00:07:53 +00:00
|
|
|
*status = U_BUFFER_OVERFLOW_ERROR;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|