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