Logo Search packages:      
Sourcecode: icu version File versions

int32_t UnicodeString::extract ( int32_t  start,
int32_t  startLength,
char *  target,
int32_t  targetCapacity,
enum EInvariant  inv 
) const

Copy the characters in the range [start, start + length) into an array of characters. All characters must be invariant (see utypes.h). Use US_INV as the last, signature-distinguishing parameter.

This function does not write any more than targetLength characters but returns the length of the entire output string so that one can allocate a larger buffer and call the function again if necessary. The output string is NUL-terminated if possible.

start offset of first character which will be copied
startLength the number of characters to extract
target the target buffer for extraction, can be NULL if targetLength is 0
targetCapacity the length of the target buffer
inv Signature-distinguishing paramater, use US_INV.
the output string length, not including the terminating NUL ICU 3.2

Definition at line 761 of file unistr.cpp.

References NULL, and U_ZERO_ERROR.

  // if the arguments are illegal, then do nothing
  if(targetCapacity < 0 || (targetCapacity > 0 && target == NULL)) {
    return 0;

  // pin the indices to legal values
  pinIndices(start, length);

  if(length <= targetCapacity) {
    u_UCharsToChars(getArrayStart() + start, target, length);
  UErrorCode status = U_ZERO_ERROR;
  return u_terminateChars(target, targetCapacity, length, &status);

Generated by  Doxygen 1.6.0   Back to index