Rizin
unix-like reverse engineering framework and cli tools
utf32.c File Reference
#include <rz_types.h>
#include <rz_util.h>

Go to the source code of this file.

Functions

RZ_API int rz_utf32_decode (const ut8 *ptr, int ptrlen, RzRune *ch, bool bigendian)
 
RZ_API int rz_utf32le_decode (const ut8 *ptr, int ptrlen, RzRune *ch)
 
RZ_API int rz_utf32be_decode (const ut8 *ptr, int ptrlen, RzRune *ch)
 

Function Documentation

◆ rz_utf32_decode()

RZ_API int rz_utf32_decode ( const ut8 ptr,
int  ptrlen,
RzRune ch,
bool  bigendian 
)

Definition at line 8 of file utf32.c.

8  {
9  if (ptrlen < 1) {
10  return 0;
11  }
12  int low = 0;
13  int high = 3;
14  if (bigendian) {
15  low = 3;
16  high = 0;
17  }
18  if (ptrlen > 3) {
19  int sign = bigendian ? -1 : 1;
20  if (ch) {
21  int i;
22  *ch = (ut32)ptr[low];
23  for (i = 1; i < 4; i++) {
24  *ch |= (ut32)ptr[3 - high + i * sign] << 8 * i;
25  }
26  }
27  if (ptr[high] || ptr[high - 1 * sign]) {
28  return 4;
29  }
30  if (ptr[low + 1 * sign]) {
31  return 2;
32  }
33  return 1;
34  }
35  return 0;
36 }
lzma_index ** i
Definition: index.h:629
uint32_t ut32

References i.

Referenced by rz_str_escape_utf(), rz_utf32be_decode(), and rz_utf32le_decode().

◆ rz_utf32be_decode()

RZ_API int rz_utf32be_decode ( const ut8 ptr,
int  ptrlen,
RzRune ch 
)

Definition at line 44 of file utf32.c.

44  {
45  return rz_utf32_decode(ptr, ptrlen, ch, true);
46 }
RZ_API int rz_utf32_decode(const ut8 *ptr, int ptrlen, RzRune *ch, bool bigendian)
Definition: utf32.c:8

References rz_utf32_decode().

Referenced by process_one_string(), and rz_str_stringify_raw_buffer().

◆ rz_utf32le_decode()

RZ_API int rz_utf32le_decode ( const ut8 ptr,
int  ptrlen,
RzRune ch 
)

Definition at line 39 of file utf32.c.

39  {
40  return rz_utf32_decode(ptr, ptrlen, ch, false);
41 }

References rz_utf32_decode().

Referenced by ds_esc_str(), process_one_string(), and rz_str_stringify_raw_buffer().