michael@0: /* michael@0: ******************************************************************************* michael@0: * michael@0: * Copyright (C) 2000, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: * michael@0: ******************************************************************************* michael@0: * michael@0: * File writejava.c michael@0: * michael@0: * Modification History: michael@0: * michael@0: * Date Name Description michael@0: * 01/11/02 Ram Creation. michael@0: ******************************************************************************* michael@0: */ michael@0: michael@0: #ifndef RLE_H michael@0: #define RLE_H 1 michael@0: michael@0: #include "unicode/utypes.h" michael@0: #include "unicode/ustring.h" michael@0: michael@0: U_CDECL_BEGIN michael@0: /** michael@0: * Construct a string representing a byte array. Use run-length encoding. michael@0: * Two bytes are packed into a single char, with a single extra zero byte at michael@0: * the end if needed. A byte represents itself, unless it is the michael@0: * ESCAPE_BYTE. Then the following notations are possible: michael@0: * ESCAPE_BYTE ESCAPE_BYTE ESCAPE_BYTE literal michael@0: * ESCAPE_BYTE n b n instances of byte b michael@0: * Since an encoded run occupies 3 bytes, we only encode runs of 4 or michael@0: * more bytes. Thus we have n > 0 and n != ESCAPE_BYTE and n <= 0xFF. michael@0: * If we encounter a run where n == ESCAPE_BYTE, we represent this as: michael@0: * b ESCAPE_BYTE n-1 b michael@0: * The ESCAPE_BYTE value is chosen so as not to collide with commonly michael@0: * seen values. michael@0: */ michael@0: int32_t michael@0: byteArrayToRLEString(const uint8_t* src,int32_t srcLen, uint16_t* buffer,int32_t bufLen, UErrorCode* status); michael@0: michael@0: michael@0: /** michael@0: * Construct a string representing a char array. Use run-length encoding. michael@0: * A character represents itself, unless it is the ESCAPE character. Then michael@0: * the following notations are possible: michael@0: * ESCAPE ESCAPE ESCAPE literal michael@0: * ESCAPE n c n instances of character c michael@0: * Since an encoded run occupies 3 characters, we only encode runs of 4 or michael@0: * more characters. Thus we have n > 0 and n != ESCAPE and n <= 0xFFFF. michael@0: * If we encounter a run where n == ESCAPE, we represent this as: michael@0: * c ESCAPE n-1 c michael@0: * The ESCAPE value is chosen so as not to collide with commonly michael@0: * seen values. michael@0: */ michael@0: int32_t michael@0: usArrayToRLEString(const uint16_t* src,int32_t srcLen,uint16_t* buffer, int32_t bufLen,UErrorCode* status); michael@0: michael@0: /** michael@0: * Construct an array of bytes from a run-length encoded string. michael@0: */ michael@0: int32_t michael@0: rleStringToByteArray(uint16_t* src, int32_t srcLen, uint8_t* target, int32_t tgtLen, UErrorCode* status); michael@0: /** michael@0: * Construct an array of shorts from a run-length encoded string. michael@0: */ michael@0: int32_t michael@0: rleStringToUCharArray(uint16_t* src, int32_t srcLen, uint16_t* target, int32_t tgtLen, UErrorCode* status); michael@0: michael@0: U_CDECL_END michael@0: michael@0: #endif