home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / common / cpputils.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-19  |  968 b   |  35 lines

  1. #define  EXTENDED_FUNCTIONALITY
  2. #include "cpputils.h"
  3. #include "cstring.h"
  4. #include "ustring.h"
  5.  
  6.  
  7.  
  8. /******************************************************
  9.  * Simple utility to set output buffer parameters
  10.  ******************************************************/
  11. void T_fillOutputParams(const UnicodeString* temp,
  12.             UChar* result, 
  13.             const int32_t resultLength,
  14.             int32_t* resultLengthOut, 
  15.             UErrorCode* status) 
  16. {
  17.   
  18.   const int32_t actual = temp->size();
  19.   const bool_t overflowed = actual >= resultLength;
  20.   const int32_t returnedSize = icu_min(actual, resultLength-1);
  21.   if ((temp->size() < resultLength) && (result != temp->getUChars()) && (returnedSize > 0)) {
  22.     u_strcpy(result, temp->getUChars());
  23.   }
  24.   
  25.   if (resultLength > 0) {
  26.     result[returnedSize] = 0;
  27.   }
  28.   if (resultLengthOut) {
  29.     *resultLengthOut = actual;
  30.     if (U_SUCCESS(*status) && overflowed) {
  31.       *status = U_BUFFER_OVERFLOW_ERROR;
  32.     }
  33.   }
  34. }
  35.