Wireshark 4.5.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Macros | Functions | Variables
unicode-utils.h File Reference
#include <wireshark.h>

Go to the source code of this file.

Macros

#define DEBUG_UTF_8_ENABLED   false
 
#define _CHECK_UTF_8(level, str, len)
 
#define WS_UTF_8_CHECK(str, len)    _CHECK_UTF_8(LOG_LEVEL_DEBUG, str, len)
 
#define WS_UTF_8_DEBUG_HERE(str, len)    _CHECK_UTF_8(LOG_LEVEL_ECHO, str, len)
 
#define ws_utf8_char_len(ch)   (ws_utf8_seqlen[(ch)])
 
#define IS_LEAD_SURROGATE(uchar2)    ((uchar2) >= 0xd800 && (uchar2) < 0xdc00)
 
#define IS_TRAIL_SURROGATE(uchar2)    ((uchar2) >= 0xdc00 && (uchar2) < 0xe000)
 
#define SURROGATE_VALUE(lead, trail)    (((((lead) - 0xd800) << 10) | ((trail) - 0xdc00)) + 0x10000)
 

Functions

WS_DLL_PUBLIC uint8_t * ws_utf8_make_valid (wmem_allocator_t *scope, const uint8_t *ptr, ssize_t length)
 
WS_DLL_PUBLIC wmem_strbuf_tws_utf8_make_valid_strbuf (wmem_allocator_t *scope, const uint8_t *ptr, ssize_t length)
 

Variables

WSUTIL_EXPORT const int ws_utf8_seqlen [256]
 

Detailed Description

Unicode convenience routines.

Macro Definition Documentation

◆ _CHECK_UTF_8

#define _CHECK_UTF_8 (   level,
  str,
  len 
)
Value:
do { \
const char *__uni_endptr; \
if (DEBUG_UTF_8_ENABLED && (str) != NULL && \
!g_utf8_validate(str, len, &__uni_endptr)) { \
ws_log_utf8(str, len, __uni_endptr); \
} \
} while (0)

◆ ws_utf8_char_len

#define ws_utf8_char_len (   ch)    (ws_utf8_seqlen[(ch)])

Given the first byte in an UTF-8 encoded code point, return the length of the multibyte sequence, or ZERO if the byte is invalid as the first byte in a multibyte sequence.