]>
git.saurik.com Git - apple/icu.git/blob - icuSources/tools/genrb/rle.h
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
6 * Copyright (C) 2000, International Business Machines
7 * Corporation and others. All Rights Reserved.
9 *******************************************************************************
13 * Modification History:
15 * Date Name Description
16 * 01/11/02 Ram Creation.
17 *******************************************************************************
23 #include "unicode/utypes.h"
24 #include "unicode/ustring.h"
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:
38 * The ESCAPE_BYTE value is chosen so as not to collide with commonly
42 byteArrayToRLEString(const uint8_t* src
,int32_t srcLen
, uint16_t* buffer
,int32_t bufLen
, UErrorCode
* status
);
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:
55 * The ESCAPE value is chosen so as not to collide with commonly
59 usArrayToRLEString(const uint16_t* src
,int32_t srcLen
,uint16_t* buffer
, int32_t bufLen
,UErrorCode
* status
);
62 * Construct an array of bytes from a run-length encoded string.
65 rleStringToByteArray(uint16_t* src
, int32_t srcLen
, uint8_t* target
, int32_t tgtLen
, UErrorCode
* status
);
67 * Construct an array of shorts from a run-length encoded string.
70 rleStringToUCharArray(uint16_t* src
, int32_t srcLen
, uint16_t* target
, int32_t tgtLen
, UErrorCode
* status
);