1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************* 5 * 6 * Copyright (C) 2000, International Business Machines 7 * Corporation and others. All Rights Reserved. 8 * 9 ******************************************************************************* 10 * 11 * File writejava.c 12 * 13 * Modification History: 14 * 15 * Date Name Description 16 * 01/11/02 Ram Creation. 17 ******************************************************************************* 18 */ 19 20 #ifndef RLE_H 21 #define RLE_H 1 22 23 #include "unicode/utypes.h" 24 #include "unicode/ustring.h" 25 26 U_CDECL_BEGIN 27 /** 28 * Construct a string representing a byte array. Use run-length encoding. 29 * Two bytes are packed into a single char, with a single extra zero byte at 30 * the end if needed. A byte represents itself, unless it is the 31 * ESCAPE_BYTE. Then the following notations are possible: 32 * ESCAPE_BYTE ESCAPE_BYTE ESCAPE_BYTE literal 33 * ESCAPE_BYTE n b n instances of byte b 34 * Since an encoded run occupies 3 bytes, we only encode runs of 4 or 35 * more bytes. Thus we have n > 0 and n != ESCAPE_BYTE and n <= 0xFF. 36 * If we encounter a run where n == ESCAPE_BYTE, we represent this as: 37 * b ESCAPE_BYTE n-1 b 38 * The ESCAPE_BYTE value is chosen so as not to collide with commonly 39 * seen values. 40 */ 41 int32_t 42 byteArrayToRLEString(const uint8_t* src,int32_t srcLen, uint16_t* buffer,int32_t bufLen, UErrorCode* status); 43 44 45 /** 46 * Construct a string representing a char array. Use run-length encoding. 47 * A character represents itself, unless it is the ESCAPE character. Then 48 * the following notations are possible: 49 * ESCAPE ESCAPE ESCAPE literal 50 * ESCAPE n c n instances of character c 51 * Since an encoded run occupies 3 characters, we only encode runs of 4 or 52 * more characters. Thus we have n > 0 and n != ESCAPE and n <= 0xFFFF. 53 * If we encounter a run where n == ESCAPE, we represent this as: 54 * c ESCAPE n-1 c 55 * The ESCAPE value is chosen so as not to collide with commonly 56 * seen values. 57 */ 58 int32_t 59 usArrayToRLEString(const uint16_t* src,int32_t srcLen,uint16_t* buffer, int32_t bufLen,UErrorCode* status); 60 61 /** 62 * Construct an array of bytes from a run-length encoded string. 63 */ 64 int32_t 65 rleStringToByteArray(uint16_t* src, int32_t srcLen, uint8_t* target, int32_t tgtLen, UErrorCode* status); 66 /** 67 * Construct an array of shorts from a run-length encoded string. 68 */ 69 int32_t 70 rleStringToUCharArray(uint16_t* src, int32_t srcLen, uint16_t* target, int32_t tgtLen, UErrorCode* status); 71 72 U_CDECL_END 73 74 #endif 75