12e5b6d6dSopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 22e5b6d6dSopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 32e5b6d6dSopenharmony_ci/* 42e5b6d6dSopenharmony_ci******************************************************************************* 52e5b6d6dSopenharmony_ci* 62e5b6d6dSopenharmony_ci* Copyright (C) 2000, International Business Machines 72e5b6d6dSopenharmony_ci* Corporation and others. All Rights Reserved. 82e5b6d6dSopenharmony_ci* 92e5b6d6dSopenharmony_ci******************************************************************************* 102e5b6d6dSopenharmony_ci* 112e5b6d6dSopenharmony_ci* File writejava.c 122e5b6d6dSopenharmony_ci* 132e5b6d6dSopenharmony_ci* Modification History: 142e5b6d6dSopenharmony_ci* 152e5b6d6dSopenharmony_ci* Date Name Description 162e5b6d6dSopenharmony_ci* 01/11/02 Ram Creation. 172e5b6d6dSopenharmony_ci******************************************************************************* 182e5b6d6dSopenharmony_ci*/ 192e5b6d6dSopenharmony_ci 202e5b6d6dSopenharmony_ci#ifndef RLE_H 212e5b6d6dSopenharmony_ci#define RLE_H 1 222e5b6d6dSopenharmony_ci 232e5b6d6dSopenharmony_ci#include "unicode/utypes.h" 242e5b6d6dSopenharmony_ci#include "unicode/ustring.h" 252e5b6d6dSopenharmony_ci 262e5b6d6dSopenharmony_ciU_CDECL_BEGIN 272e5b6d6dSopenharmony_ci/** 282e5b6d6dSopenharmony_ci * Construct a string representing a byte array. Use run-length encoding. 292e5b6d6dSopenharmony_ci * Two bytes are packed into a single char, with a single extra zero byte at 302e5b6d6dSopenharmony_ci * the end if needed. A byte represents itself, unless it is the 312e5b6d6dSopenharmony_ci * ESCAPE_BYTE. Then the following notations are possible: 322e5b6d6dSopenharmony_ci * ESCAPE_BYTE ESCAPE_BYTE ESCAPE_BYTE literal 332e5b6d6dSopenharmony_ci * ESCAPE_BYTE n b n instances of byte b 342e5b6d6dSopenharmony_ci * Since an encoded run occupies 3 bytes, we only encode runs of 4 or 352e5b6d6dSopenharmony_ci * more bytes. Thus we have n > 0 and n != ESCAPE_BYTE and n <= 0xFF. 362e5b6d6dSopenharmony_ci * If we encounter a run where n == ESCAPE_BYTE, we represent this as: 372e5b6d6dSopenharmony_ci * b ESCAPE_BYTE n-1 b 382e5b6d6dSopenharmony_ci * The ESCAPE_BYTE value is chosen so as not to collide with commonly 392e5b6d6dSopenharmony_ci * seen values. 402e5b6d6dSopenharmony_ci */ 412e5b6d6dSopenharmony_ciint32_t 422e5b6d6dSopenharmony_cibyteArrayToRLEString(const uint8_t* src,int32_t srcLen, uint16_t* buffer,int32_t bufLen, UErrorCode* status); 432e5b6d6dSopenharmony_ci 442e5b6d6dSopenharmony_ci 452e5b6d6dSopenharmony_ci/** 462e5b6d6dSopenharmony_ci * Construct a string representing a char array. Use run-length encoding. 472e5b6d6dSopenharmony_ci * A character represents itself, unless it is the ESCAPE character. Then 482e5b6d6dSopenharmony_ci * the following notations are possible: 492e5b6d6dSopenharmony_ci * ESCAPE ESCAPE ESCAPE literal 502e5b6d6dSopenharmony_ci * ESCAPE n c n instances of character c 512e5b6d6dSopenharmony_ci * Since an encoded run occupies 3 characters, we only encode runs of 4 or 522e5b6d6dSopenharmony_ci * more characters. Thus we have n > 0 and n != ESCAPE and n <= 0xFFFF. 532e5b6d6dSopenharmony_ci * If we encounter a run where n == ESCAPE, we represent this as: 542e5b6d6dSopenharmony_ci * c ESCAPE n-1 c 552e5b6d6dSopenharmony_ci * The ESCAPE value is chosen so as not to collide with commonly 562e5b6d6dSopenharmony_ci * seen values. 572e5b6d6dSopenharmony_ci */ 582e5b6d6dSopenharmony_ciint32_t 592e5b6d6dSopenharmony_ciusArrayToRLEString(const uint16_t* src,int32_t srcLen,uint16_t* buffer, int32_t bufLen,UErrorCode* status); 602e5b6d6dSopenharmony_ci 612e5b6d6dSopenharmony_ci/** 622e5b6d6dSopenharmony_ci * Construct an array of bytes from a run-length encoded string. 632e5b6d6dSopenharmony_ci */ 642e5b6d6dSopenharmony_ciint32_t 652e5b6d6dSopenharmony_cirleStringToByteArray(uint16_t* src, int32_t srcLen, uint8_t* target, int32_t tgtLen, UErrorCode* status); 662e5b6d6dSopenharmony_ci/** 672e5b6d6dSopenharmony_ci * Construct an array of shorts from a run-length encoded string. 682e5b6d6dSopenharmony_ci */ 692e5b6d6dSopenharmony_ciint32_t 702e5b6d6dSopenharmony_cirleStringToUCharArray(uint16_t* src, int32_t srcLen, uint16_t* target, int32_t tgtLen, UErrorCode* status); 712e5b6d6dSopenharmony_ci 722e5b6d6dSopenharmony_ciU_CDECL_END 732e5b6d6dSopenharmony_ci 742e5b6d6dSopenharmony_ci#endif 75