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