Logo Search packages:      
Sourcecode: icu version File versions  Download package

U_STABLE int32_t U_EXPORT2 ubidi_writeReverse ( const UChar *  src,
int32_t  srcLength,
UChar *  dest,
int32_t  destSize,
uint16_t  options,
UErrorCode pErrorCode 
)

Reverse a Right-To-Left run of Unicode text.

This function preserves the integrity of characters with multiple code units and (optionally) combining characters. Characters can be replaced by mirror-image characters in the destination buffer. Note that "real" mirroring has to be done in a rendering engine by glyph selection and that for many "mirrored" characters there are no Unicode characters as mirror-image equivalents. There are also options to insert or remove Bidi control characters.

This function is the implementation for reversing RTL runs as part of ubidi_writeReordered(). For detailed descriptions of the parameters, see there. Since no Bidi controls are inserted here, the output string length will never exceed srcLength.

See also:
ubidi_writeReordered
Parameters:
src A pointer to the RTL run text.
srcLength The length of the RTL run.
dest A pointer to where the reordered text is to be copied. src[srcLength] and dest[destSize] must not overlap.
destSize The size of the dest buffer, in number of UChars. If the UBIDI_REMOVE_BIDI_CONTROLS option is set, then the destination length may be less than srcLength. If this option is not set, then the destination length will be exactly srcLength.
options A bit set of options for the reordering that control how the reordered text is written. See the options parameter in ubidi_writeReordered().
pErrorCode must be a valid pointer to an error code value.
Returns:
The length of the output string. ICU 2.0

Definition at line 311 of file ubidiwrt.c.

References NULL, U_FAILURE, U_ILLEGAL_ARGUMENT_ERROR, and u_strlen().

                                           {
    int32_t destLength;

    if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
        return 0;
    }

    /* more error checking */
    if( src==NULL || srcLength<-1 ||
        destSize<0 || (destSize>0 && dest==NULL))
    {
        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
        return 0;
    }

    /* do input and output overlap? */
    if( dest!=NULL &&
        ((src>=dest && src<dest+destSize) ||
         (dest>=src && dest<src+srcLength)))
    {
        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
        return 0;
    }

    if(srcLength==-1) {
        srcLength=u_strlen(src);
    }
    if(srcLength>0) {
        destLength=doWriteReverse(src, srcLength, dest, destSize, options, pErrorCode);
    } else {
        /* nothing to do */
        destLength=0;
    }

    return u_terminateUChars(dest, destSize, destLength, pErrorCode);
}


Generated by  Doxygen 1.6.0   Back to index