Wireshark 4.7.0
The Wireshark network protocol analyzer
Loading...
Searching...
No Matches
Macros | Functions | Variables
to_str.h File Reference
#include <wireshark.h>
#include <wsutil/wmem/wmem.h>
#include <wsutil/inet_addr.h>
#include <wsutil/nstime.h>

Go to the source code of this file.

Macros

#define bytes_to_str_punct(scope, buf, buf_size, punct)    bytes_to_str_punct_maxlen(scope, buf, buf_size, punct, 24)
 
#define bytes_to_str(scope, buf, buf_size)    bytes_to_str_maxlen(scope, buf, buf_size, 36)
 

Functions

WS_DLL_PUBLIC char * uint8_to_hex (char *out, uint8_t val)
 
WS_DLL_PUBLIC char * word_to_hex (char *out, uint16_t word)
 Converts a 16-bit word to a fixed-width hexadecimal string.
 
WS_DLL_PUBLIC char * word_to_hex_punct (char *out, uint16_t word, char punct)
 Converts a 16-bit word to a hexadecimal string with byte-level punctuation.
 
WS_DLL_PUBLIC char * word_to_hex_npad (char *out, uint16_t word)
 Converts a 16-bit word to a hexadecimal string without padding.
 
WS_DLL_PUBLIC char * dword_to_hex (char *out, uint32_t dword)
 Converts a 32-bit word to a fixed-width hexadecimal string.
 
WS_DLL_PUBLIC char * dword_to_hex_punct (char *out, uint32_t dword, char punct)
 Converts a 32-bit word to a hexadecimal string with punctuation.
 
WS_DLL_PUBLIC char * qword_to_hex (char *out, uint64_t qword)
 Converts a 64-bit word to a fixed-width hexadecimal string.
 
WS_DLL_PUBLIC char * qword_to_hex_punct (char *out, uint64_t qword, char punct)
 Converts a 64-bit word to a hexadecimal string with punctuation.
 
WS_DLL_PUBLIC char * bytes_to_hexstr (char *out, const uint8_t *ad, size_t len)
 Converts a byte array to a hexadecimal string.
 
WS_DLL_PUBLIC char * bytes_to_hexstr_punct (char *out, const uint8_t *ad, size_t len, char punct)
 Converts a byte array to a hexadecimal string with punctuation.
 
WS_DLL_PUBLIC char * bytes_to_str_punct_maxlen (wmem_allocator_t *scope, const uint8_t *buf, size_t buf_size, char punct, size_t max_bytes_len)
 Turn an array of bytes into a string showing the bytes in hex, separated by a punctuation character.
 
WS_DLL_PUBLIC char * bytes_to_str_maxlen (wmem_allocator_t *scope, const uint8_t *buf, size_t buf_size, size_t max_bytes_len)
 Turn an array of bytes into a string showing the bytes in hex.
 
WS_DLL_PUBLIC char * oct_to_str_back (char *ptr, uint32_t value)
 Converts a 32-bit unsigned integer to octal string in reverse.
 
WS_DLL_PUBLIC char * oct64_to_str_back (char *ptr, uint64_t value)
 Converts a 64-bit unsigned integer to octal string in reverse.
 
WS_DLL_PUBLIC char * hex_to_str_back_len (char *ptr, uint32_t value, int len)
 Converts a 32-bit unsigned integer to hex string in reverse with fixed length.
 
WS_DLL_PUBLIC char * hex64_to_str_back_len (char *ptr, uint64_t value, int len)
 Converts a 64-bit unsigned integer to hex string in reverse with fixed length.
 
WS_DLL_PUBLIC char * uint_to_str_back (char *ptr, uint32_t value)
 Converts a 32-bit unsigned integer to decimal string in reverse.
 
WS_DLL_PUBLIC char * uint64_to_str_back (char *ptr, uint64_t value)
 Converts a 64-bit unsigned integer to a decimal string in reverse.
 
WS_DLL_PUBLIC char * uint_to_str_back_len (char *ptr, uint32_t value, int len)
 Converts a 32-bit unsigned integer to a zero-padded decimal string in reverse.
 
WS_DLL_PUBLIC char * uint64_to_str_back_len (char *ptr, uint64_t value, int len)
 Converts a 64-bit unsigned integer to a zero-padded decimal string in reverse.
 
WS_DLL_PUBLIC char * int_to_str_back (char *ptr, int32_t value)
 Converts a 32-bit signed integer to a decimal string in reverse.
 
WS_DLL_PUBLIC char * int64_to_str_back (char *ptr, int64_t value)
 Converts a 64-bit signed integer to a decimal string in reverse.
 
WS_DLL_PUBLIC void uint32_to_str_buf (uint32_t u, char *buf, size_t buf_len)
 Converts a 32-bit unsigned integer to a decimal string.
 
WS_DLL_PUBLIC void uint64_to_str_buf (uint64_t u, char *buf, size_t buf_len)
 Converts a 64-bit unsigned integer to a decimal string.
 
 WS_DEPRECATED_X ("Use ip_num_to_str_buf() or ip_addr_to_str() instead") WS_DLL_PUBLIC void ip_to_str_buf(const uint8_t *ad
 
 WS_DEPRECATED_X ("Use ip_num_to_str() or ip_addr_to_str() instead") WS_DLL_PUBLIC char *ip_to_str(wmem_allocator_t *scope
 
WS_DLL_PUBLIC void ip_num_to_str_buf (uint32_t ad, char *buf, const int buf_len)
 Converts a 32-bit IPv4 address to string format.
 
WS_DLL_PUBLIC char * ip_num_to_str (wmem_allocator_t *scope, uint32_t ad)
 Converts a 32-bit IPv4 address to a string using memory scope.
 
WS_DLL_PUBLIC void ip_addr_to_str_buf (const ws_in4_addr *ad, char *buf, const int buf_len)
 Converts a ws_in4_addr structure to string format.
 
WS_DLL_PUBLIC char * ip_addr_to_str (wmem_allocator_t *scope, const ws_in4_addr *ad)
 Converts a ws_in4_addr structure to a string using memory scope.
 
WS_DLL_PUBLIC void ip6_to_str_buf (const ws_in6_addr *ad, char *buf, size_t buf_size)
 Converts a ws_in6_addr structure to string format.
 
WS_DLL_PUBLIC char * ip6_to_str (wmem_allocator_t *scope, const ws_in6_addr *ad)
 Converts a ws_in6_addr structure to a string using memory scope.
 
WS_DLL_PUBLIC char * ipxnet_to_str_punct (wmem_allocator_t *scope, const uint32_t ad, const char punct)
 Converts an IPX network address to a string with punctuation.
 
WS_DLL_PUBLIC char * eui64_to_str (wmem_allocator_t *scope, const uint64_t ad)
 Converts a 64-bit EUI-64 address to string format.
 
WS_DLL_PUBLIC int format_fractional_part_nsecs (char *buf, size_t buflen, uint32_t nsecs, const char *decimal_point, int precision)
 Formats the fractional part of a timestamp in nanoseconds.
 
WS_DLL_PUBLIC void display_epoch_time (char *buf, size_t buflen, const nstime_t *ns, int precision)
 Formats an epoch time value for display.
 
WS_DLL_PUBLIC void display_signed_time (char *buf, size_t buf_size, const nstime_t *nstime, int precision)
 Formats a signed time value for display.
 
WS_DLL_PUBLIC void format_nstime_as_iso8601 (char *buf, size_t buf_size, const nstime_t *nstime, char *frac_buf, bool include_tz, int precision)
 Formats an nstime_t value as an ISO 8601 timestamp.
 

Variables

char * buf
 
char const int buf_len
 
const uint8_t * ad
 

Detailed Description

Definitions for utilities to convert various other types to strings.

Wireshark - Network traffic analyzer By Gerald Combs geral.nosp@m.d@wi.nosp@m.resha.nosp@m.rk.o.nosp@m.rg Copyright 1998 Gerald Combs

SPDX-License-Identifier: GPL-2.0-or-later

Function Documentation

◆ bytes_to_hexstr()

WS_DLL_PUBLIC char * bytes_to_hexstr ( char *  out,
const uint8_t *  ad,
size_t  len 
)

Converts a byte array to a hexadecimal string.

Writes the hexadecimal representation of a byte array to the provided buffer. Each byte is represented by two hex characters. The result is not NUL-terminated. The caller must ensure the buffer has at least len * 2 bytes.

Parameters
outPointer to the destination buffer.
adPointer to the byte array.
lenNumber of bytes in the array.
Returns
Pointer to the position immediately after the last written character.

◆ bytes_to_hexstr_punct()

WS_DLL_PUBLIC char * bytes_to_hexstr_punct ( char *  out,
const uint8_t *  ad,
size_t  len,
char  punct 
)

Converts a byte array to a hexadecimal string with punctuation.

Writes the hexadecimal representation of a byte array to the provided buffer, inserting the specified punctuation character between each byte. Each byte is represented by two hex digits, and the output is not NUL-terminated. The caller must ensure the buffer has at least (len * 3) - 1 bytes.

Example: For input {0xAB, 0xCD, 0xEF} and ‘punct = ’:', the output will be"AB:CD:EF"`.

Parameters
outPointer to the destination buffer.
adPointer to the byte array to convert.
lenNumber of bytes in the array.
punctThe punctuation character to insert between bytes (must not be NUL).
Returns
Pointer to the position immediately after the last written character.

◆ bytes_to_str_maxlen()

WS_DLL_PUBLIC char * bytes_to_str_maxlen ( wmem_allocator_t scope,
const uint8_t *  buf,
size_t  buf_size,
size_t  max_bytes_len 
)

Turn an array of bytes into a string showing the bytes in hex.

Parameters
scopememory allocation scheme used
bufA pointer to the byte array
buf_sizeThe length of the byte array
max_bytes_lenMaximum number of bytes to represent, zero for no limit.
Returns
A pointer to the formatted string

◆ bytes_to_str_punct_maxlen()

WS_DLL_PUBLIC char * bytes_to_str_punct_maxlen ( wmem_allocator_t scope,
const uint8_t *  buf,
size_t  buf_size,
char  punct,
size_t  max_bytes_len 
)

Turn an array of bytes into a string showing the bytes in hex, separated by a punctuation character.

Parameters
scopememory allocation scheme used
bufA pointer to the byte array
buf_sizeThe length of the byte array
punctThe punctuation character
max_bytes_lenMaximum number of bytes to represent, zero for no limit.
Returns
A pointer to the formatted string

◆ display_epoch_time()

WS_DLL_PUBLIC void display_epoch_time ( char *  buf,
size_t  buflen,
const nstime_t ns,
int  precision 
)

Formats an epoch time value for display.

Converts an nstime_t value to a human-readable string representing the epoch time.

Parameters
bufDestination buffer.
buflenSize of the buffer.
nsPointer to the time value.
precisionNumber of fractional digits to include.

◆ display_signed_time()

WS_DLL_PUBLIC void display_signed_time ( char *  buf,
size_t  buf_size,
const nstime_t nstime,
int  precision 
)

Formats a signed time value for display.

Converts an nstime_t value to a human-readable string, preserving sign and precision.

Parameters
bufDestination buffer.
buf_sizeSize of the buffer.
nstimePointer to the time value.
precisionNumber of fractional digits to include.

◆ dword_to_hex()

WS_DLL_PUBLIC char * dword_to_hex ( char *  out,
uint32_t  dword 
)

Converts a 32-bit word to a fixed-width hexadecimal string.

Writes the zero-padded 8-character hexadecimal representation of a uint32_t value to the provided buffer. The result is not NUL-terminated. The caller must ensure the buffer has at least 8 bytes.

Parameters
outPointer to the destination buffer.
dwordThe 32-bit value to convert.
Returns
Pointer to the position immediately after the last written character.

◆ dword_to_hex_punct()

WS_DLL_PUBLIC char * dword_to_hex_punct ( char *  out,
uint32_t  dword,
char  punct 
)

Converts a 32-bit word to a hexadecimal string with punctuation.

Writes the hexadecimal representation of a uint32_t value to the buffer, inserting the specified punctuation character between each byte. The output is always 11 characters long and not NUL-terminated. The caller must ensure the buffer has at least 11 bytes.

Parameters
outPointer to the destination buffer.
dwordThe 32-bit value to convert.
punctThe punctuation character to insert (must not be NUL).
Returns
Pointer to the position immediately after the last written character.

◆ eui64_to_str()

WS_DLL_PUBLIC char * eui64_to_str ( wmem_allocator_t scope,
const uint64_t  ad 
)

Converts a 64-bit EUI-64 address to string format.

Formats the EUI-64 address as a colon-separated hexadecimal string and allocates the result using the provided memory scope.

Parameters
scopeMemory allocator scope.
adEUI-64 address.
Returns
Pointer to the allocated string.

◆ format_fractional_part_nsecs()

WS_DLL_PUBLIC int format_fractional_part_nsecs ( char *  buf,
size_t  buflen,
uint32_t  nsecs,
const char *  decimal_point,
int  precision 
)

Formats the fractional part of a timestamp in nanoseconds.

Converts the nanosecond portion of a timestamp to a string with optional formatting.

Parameters
bufDestination buffer.
buflenLength of the buffer.
nsecsNanoseconds to format.
decimal_pointString to use as the decimal point.
precisionNumber of digits to include.
Returns
Number of characters written to the buffer.

◆ format_nstime_as_iso8601()

WS_DLL_PUBLIC void format_nstime_as_iso8601 ( char *  buf,
size_t  buf_size,
const nstime_t nstime,
char *  frac_buf,
bool  include_tz,
int  precision 
)

Formats an nstime_t value as an ISO 8601 timestamp.

Converts the time value to a string in ISO 8601 format, optionally including fractional seconds.

Parameters
bufDestination buffer.
buf_sizeSize of the buffer.
nstimePointer to the time value.
frac_bufOptional buffer for fractional part.
include_tzWhether to include timezone information.
precisionNumber of fractional digits to include.

◆ hex64_to_str_back_len()

WS_DLL_PUBLIC char * hex64_to_str_back_len ( char *  ptr,
uint64_t  value,
int  len 
)

Converts a 64-bit unsigned integer to hex string in reverse with fixed length.

Writes the hexadecimal representation of value backward into the buffer, ending at ptr - 1, and returns a pointer to the first character written. The output is zero-padded to at least len characters. The result is not NUL-terminated.

Parameters
ptrPointer to the end of the buffer.
valueThe 64-bit unsigned integer to convert.
lenMinimum number of hex digits to output.
Returns
Pointer to the first character of the written hex string.

◆ hex_to_str_back_len()

WS_DLL_PUBLIC char * hex_to_str_back_len ( char *  ptr,
uint32_t  value,
int  len 
)

Converts a 32-bit unsigned integer to hex string in reverse with fixed length.

Writes the hexadecimal representation of value backward into the buffer, ending at ptr - 1, and returns a pointer to the first character written. The output is zero-padded to at least len characters. The result is not NUL-terminated.

Parameters
ptrPointer to the end of the buffer.
valueThe 32-bit unsigned integer to convert.
lenMinimum number of hex digits to output.
Returns
Pointer to the first character of the written hex string.

◆ int64_to_str_back()

WS_DLL_PUBLIC char * int64_to_str_back ( char *  ptr,
int64_t  value 
)

Converts a 64-bit signed integer to a decimal string in reverse.

Writes the decimal representation of value backward into the buffer, ending at ptr - 1, and returns a pointer to the first character written. Handles negative values by prepending a minus sign. The result is not NUL-terminated.

Parameters
ptrPointer to the end of the buffer.
valueThe 64-bit signed integer to convert.
Returns
Pointer to the first character of the written decimal string.

◆ int_to_str_back()

WS_DLL_PUBLIC char * int_to_str_back ( char *  ptr,
int32_t  value 
)

Converts a 32-bit signed integer to a decimal string in reverse.

Writes the decimal representation of value backward into the buffer, ending at ptr - 1, and returns a pointer to the first character written. Handles negative values by prepending a minus sign. The result is not NUL-terminated.

Parameters
ptrPointer to the end of the buffer.
valueThe 32-bit signed integer to convert.
Returns
Pointer to the first character of the written decimal string.

◆ ip6_to_str()

WS_DLL_PUBLIC char * ip6_to_str ( wmem_allocator_t scope,
const ws_in6_addr ad 
)

Converts a ws_in6_addr structure to a string using memory scope.

Allocates and returns the colon-separated hexadecimal representation of the IPv6 address.

Parameters
scopeMemory allocator scope.
adPointer to the IPv6 address structure.
Returns
Pointer to the allocated string.

◆ ip6_to_str_buf()

WS_DLL_PUBLIC void ip6_to_str_buf ( const ws_in6_addr ad,
char *  buf,
size_t  buf_size 
)

Converts a ws_in6_addr structure to string format.

Writes the colon-separated hexadecimal representation of the IPv6 address to the buffer.

Parameters
adPointer to the IPv6 address structure.
bufDestination buffer for the string.
buf_sizeSize of the destination buffer.

◆ ip_addr_to_str()

WS_DLL_PUBLIC char * ip_addr_to_str ( wmem_allocator_t scope,
const ws_in4_addr ad 
)

Converts a ws_in4_addr structure to a string using memory scope.

Allocates and returns the dotted-decimal representation of the IPv4 address.

Parameters
scopeMemory allocator scope.
adPointer to the IPv4 address structure.
Returns
Pointer to the allocated string.

◆ ip_addr_to_str_buf()

WS_DLL_PUBLIC void ip_addr_to_str_buf ( const ws_in4_addr ad,
char *  buf,
const int  buf_len 
)

Converts a ws_in4_addr structure to string format.

Writes the dotted-decimal representation of the IPv4 address to the buffer.

Parameters
adPointer to the IPv4 address structure.
bufDestination buffer for the string.
buf_lenSize of the destination buffer.

◆ ip_num_to_str()

WS_DLL_PUBLIC char * ip_num_to_str ( wmem_allocator_t scope,
uint32_t  ad 
)

Converts a 32-bit IPv4 address to a string using memory scope.

Converts an IPv4 address in host byte order to dotted-decimal notation and allocates the result using the provided memory scope.

Parameters
scopeMemory allocator scope.
adIPv4 address in host byte order.
Returns
Pointer to the allocated string.

◆ ip_num_to_str_buf()

WS_DLL_PUBLIC void ip_num_to_str_buf ( uint32_t  ad,
char *  buf,
const int  buf_len 
)

Converts a 32-bit IPv4 address to string format.

Converts an IPv4 address in host byte order to dotted-decimal notation and writes it to the provided buffer.

Parameters
adIPv4 address in host byte order.
bufDestination buffer for the string.
buf_lenSize of the destination buffer.

◆ ipxnet_to_str_punct()

WS_DLL_PUBLIC char * ipxnet_to_str_punct ( wmem_allocator_t scope,
const uint32_t  ad,
const char  punct 
)

Converts an IPX network address to a string with punctuation.

Formats the 32-bit IPX network address using the specified punctuation character between bytes and allocates the result using the provided memory scope.

Parameters
scopeMemory allocator scope.
adIPX network address.
punctPunctuation character to insert between bytes.
Returns
Pointer to the allocated string.

◆ oct64_to_str_back()

WS_DLL_PUBLIC char * oct64_to_str_back ( char *  ptr,
uint64_t  value 
)

Converts a 64-bit unsigned integer to octal string in reverse.

Writes the octal representation of value backward into the buffer, ending at ptr - 1, and returns a pointer to the first character written. The result is not NUL-terminated.

Parameters
ptrPointer to the end of the buffer (last character will be written at ptr - 1).
valueThe 64-bit unsigned integer to convert.
Returns
Pointer to the first character of the written octal string.

◆ oct_to_str_back()

WS_DLL_PUBLIC char * oct_to_str_back ( char *  ptr,
uint32_t  value 
)

Converts a 32-bit unsigned integer to octal string in reverse.

Writes the octal representation of value backward into the buffer, ending at ptr - 1, and returns a pointer to the first character written. The result is not NUL-terminated.

Parameters
ptrPointer to the end of the buffer (last character will be written at ptr - 1).
valueThe 32-bit unsigned integer to convert.
Returns
Pointer to the first character of the written octal string.

◆ qword_to_hex()

WS_DLL_PUBLIC char * qword_to_hex ( char *  out,
uint64_t  qword 
)

Converts a 64-bit word to a fixed-width hexadecimal string.

Writes the zero-padded 16-character hexadecimal representation of a uint64_t value to the provided buffer. The result is not NUL-terminated. The caller must ensure the buffer has at least 16 bytes.

Parameters
outPointer to the destination buffer.
qwordThe 64-bit value to convert.
Returns
Pointer to the position immediately after the last written character.

◆ qword_to_hex_punct()

WS_DLL_PUBLIC char * qword_to_hex_punct ( char *  out,
uint64_t  qword,
char  punct 
)

Converts a 64-bit word to a hexadecimal string with punctuation.

Writes the hexadecimal representation of a uint64_t value to the buffer, inserting the specified punctuation character between each byte. The output is always 22 characters long and not NUL-terminated. The caller must ensure the buffer has at least 22 bytes.

Parameters
outPointer to the destination buffer.
qwordThe 64-bit value to convert.
punctThe punctuation character to insert (must not be NUL).
Returns
Pointer to the position immediately after the last written character.

◆ uint32_to_str_buf()

WS_DLL_PUBLIC void uint32_to_str_buf ( uint32_t  u,
char *  buf,
size_t  buf_len 
)

Converts a 32-bit unsigned integer to a decimal string.

Writes the decimal representation of u into the provided buffer. The output is NUL-terminated and truncated if it exceeds buf_len - 1 characters.

Parameters
uThe 32-bit unsigned integer to convert.
bufPointer to the destination buffer.
buf_lenSize of the destination buffer, including space for the NUL terminator.

◆ uint64_to_str_back()

WS_DLL_PUBLIC char * uint64_to_str_back ( char *  ptr,
uint64_t  value 
)

Converts a 64-bit unsigned integer to a decimal string in reverse.

Writes the decimal representation of value backward into the buffer, ending at ptr - 1, and returns a pointer to the first character written. The result is not NUL-terminated.

Parameters
ptrPointer to the end of the buffer.
valueThe 64-bit unsigned integer to convert.
Returns
Pointer to the first character of the written decimal string.

◆ uint64_to_str_back_len()

WS_DLL_PUBLIC char * uint64_to_str_back_len ( char *  ptr,
uint64_t  value,
int  len 
)

Converts a 64-bit unsigned integer to a zero-padded decimal string in reverse.

Writes the decimal representation of value backward into the buffer, ending at ptr - 1, and returns a pointer to the first character written. The output is padded with zeros to ensure at least len digits. The result is not NUL-terminated.

Parameters
ptrPointer to the end of the buffer.
valueThe 64-bit unsigned integer to convert.
lenMinimum number of decimal digits to output.
Returns
Pointer to the first character of the written decimal string.

◆ uint64_to_str_buf()

WS_DLL_PUBLIC void uint64_to_str_buf ( uint64_t  u,
char *  buf,
size_t  buf_len 
)

Converts a 64-bit unsigned integer to a decimal string.

Writes the decimal representation of u into the provided buffer. The output is NUL-terminated and truncated if it exceeds buf_len - 1 characters. This function ensures safe formatting within the given buffer size.

Parameters
uThe 64-bit unsigned integer to convert.
bufPointer to the destination buffer.
buf_lenSize of the destination buffer, including space for the NUL terminator.

◆ uint8_to_hex()

WS_DLL_PUBLIC char * uint8_to_hex ( char *  out,
uint8_t  val 
)

uint8_to_hex()

Output uint8_t hex representation to 'out', and return pointer after last character (out + 2). It will always output full representation (padded with 0).

String is not NUL terminated by this routine. There needs to be at least 2 bytes in the buffer.

◆ uint_to_str_back()

WS_DLL_PUBLIC char * uint_to_str_back ( char *  ptr,
uint32_t  value 
)

Converts a 32-bit unsigned integer to decimal string in reverse.

Writes the decimal representation of value backward into the buffer, ending at ptr - 1, and returns a pointer to the first character written. The result is not NUL-terminated.

Parameters
ptrPointer to the end of the buffer.
valueThe 32-bit unsigned integer to convert.
Returns
Pointer to the first character of the written decimal string.

◆ uint_to_str_back_len()

WS_DLL_PUBLIC char * uint_to_str_back_len ( char *  ptr,
uint32_t  value,
int  len 
)

Converts a 32-bit unsigned integer to a zero-padded decimal string in reverse.

Writes the decimal representation of value backward into the buffer, ending at ptr - 1, and returns a pointer to the first character written. The output is padded with zeros to ensure at least len digits. The result is not NUL-terminated.

Parameters
ptrPointer to the end of the buffer.
valueThe 32-bit unsigned integer to convert.
lenMinimum number of decimal digits to output.
Returns
Pointer to the first character of the written decimal string.

◆ word_to_hex()

WS_DLL_PUBLIC char * word_to_hex ( char *  out,
uint16_t  word 
)

Converts a 16-bit word to a fixed-width hexadecimal string.

Writes the hexadecimal representation of a uint16_t value to the provided buffer. The output is always 4 characters long, zero-padded if necessary (e.g., 0x000A"000A"). The result is not NUL-terminated, and the caller must ensure the buffer has at least 4 bytes.

Parameters
outPointer to the destination buffer (must have space for at least 4 characters).
wordThe 16-bit value to convert.
Returns
Pointer to the position immediately after the last written character (out + 4).

◆ word_to_hex_npad()

WS_DLL_PUBLIC char * word_to_hex_npad ( char *  out,
uint16_t  word 
)

Converts a 16-bit word to a hexadecimal string without padding.

Writes the hexadecimal representation of a uint16_t value to the provided buffer. The output is not zero-padded and is not NUL-terminated. The caller must ensure the buffer has at least 4 bytes.

Parameters
outPointer to the destination buffer.
wordThe 16-bit value to convert.
Returns
Pointer to the position immediately after the last written character.

◆ word_to_hex_punct()

WS_DLL_PUBLIC char * word_to_hex_punct ( char *  out,
uint16_t  word,
char  punct 
)

Converts a 16-bit word to a hexadecimal string with byte-level punctuation.

Writes the hexadecimal representation of a uint16_t value to the provided buffer, inserting the specified punctuation character between the high and low bytes. The output is always 5 characters long (e.g., "12:34" for 0x1234 with ‘’:'`). The result is not NUL-terminated, and the caller must ensure the buffer has at least 5 bytes.

Parameters
outPointer to the destination buffer (must have space for at least 5 characters).
wordThe 16-bit value to convert.
punctThe punctuation character to insert between bytes (must not be NUL).
Returns
Pointer to the position immediately after the last written character (out + 5).