1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/tools/genrb/rle.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +/* 1.5 +******************************************************************************* 1.6 +* 1.7 +* Copyright (C) 2000, International Business Machines 1.8 +* Corporation and others. All Rights Reserved. 1.9 +* 1.10 +******************************************************************************* 1.11 +* 1.12 +* File writejava.c 1.13 +* 1.14 +* Modification History: 1.15 +* 1.16 +* Date Name Description 1.17 +* 01/11/02 Ram Creation. 1.18 +******************************************************************************* 1.19 +*/ 1.20 + 1.21 +#ifndef RLE_H 1.22 +#define RLE_H 1 1.23 + 1.24 +#include "unicode/utypes.h" 1.25 +#include "unicode/ustring.h" 1.26 + 1.27 +U_CDECL_BEGIN 1.28 +/** 1.29 + * Construct a string representing a byte array. Use run-length encoding. 1.30 + * Two bytes are packed into a single char, with a single extra zero byte at 1.31 + * the end if needed. A byte represents itself, unless it is the 1.32 + * ESCAPE_BYTE. Then the following notations are possible: 1.33 + * ESCAPE_BYTE ESCAPE_BYTE ESCAPE_BYTE literal 1.34 + * ESCAPE_BYTE n b n instances of byte b 1.35 + * Since an encoded run occupies 3 bytes, we only encode runs of 4 or 1.36 + * more bytes. Thus we have n > 0 and n != ESCAPE_BYTE and n <= 0xFF. 1.37 + * If we encounter a run where n == ESCAPE_BYTE, we represent this as: 1.38 + * b ESCAPE_BYTE n-1 b 1.39 + * The ESCAPE_BYTE value is chosen so as not to collide with commonly 1.40 + * seen values. 1.41 + */ 1.42 +int32_t 1.43 +byteArrayToRLEString(const uint8_t* src,int32_t srcLen, uint16_t* buffer,int32_t bufLen, UErrorCode* status); 1.44 + 1.45 + 1.46 +/** 1.47 + * Construct a string representing a char array. Use run-length encoding. 1.48 + * A character represents itself, unless it is the ESCAPE character. Then 1.49 + * the following notations are possible: 1.50 + * ESCAPE ESCAPE ESCAPE literal 1.51 + * ESCAPE n c n instances of character c 1.52 + * Since an encoded run occupies 3 characters, we only encode runs of 4 or 1.53 + * more characters. Thus we have n > 0 and n != ESCAPE and n <= 0xFFFF. 1.54 + * If we encounter a run where n == ESCAPE, we represent this as: 1.55 + * c ESCAPE n-1 c 1.56 + * The ESCAPE value is chosen so as not to collide with commonly 1.57 + * seen values. 1.58 + */ 1.59 +int32_t 1.60 +usArrayToRLEString(const uint16_t* src,int32_t srcLen,uint16_t* buffer, int32_t bufLen,UErrorCode* status); 1.61 + 1.62 +/** 1.63 + * Construct an array of bytes from a run-length encoded string. 1.64 + */ 1.65 +int32_t 1.66 +rleStringToByteArray(uint16_t* src, int32_t srcLen, uint8_t* target, int32_t tgtLen, UErrorCode* status); 1.67 +/** 1.68 + * Construct an array of shorts from a run-length encoded string. 1.69 + */ 1.70 +int32_t 1.71 +rleStringToUCharArray(uint16_t* src, int32_t srcLen, uint16_t* target, int32_t tgtLen, UErrorCode* status); 1.72 + 1.73 +U_CDECL_END 1.74 + 1.75 +#endif