Go to the source code of this file.
Functions | |
unsigned long | dkenc_ntohl (unsigned long l) |
Convert long (32 bit integer) from network byte order to host byte order. | |
unsigned long | dkenc_htonl (unsigned long l) |
Convert long (32 bit integer) from host byte order to network byte order. | |
unsigned short | dkenc_ntohs (unsigned short s) |
Convert short (16 bit integer) from network byte order to host byte order. | |
unsigned short | dkenc_htons (unsigned short s) |
Convert short (16 bit integer) from host byte order to network byte order. | |
int | dkenc_utf82uc (dk_udword *ucp, dk_ubyte *u8p, size_t u8l, size_t *u8u) |
Convert an UTF-8 encoded character into the appropriate 32 bit character. | |
size_t | dkenc_uc2utf8 (dk_udword c, dk_ubyte *u8p, size_t u8l) |
Convert 32-bit character to UTF-8. | |
int | dkenc_ipaddr_to_ul (char *s, unsigned long *u) |
Convert text IP address to unsigned long in host representation. | |
char * | dkenc_str_utf82bits8 (char *s, int *p) |
Convert UTF-8 encoded string to 8-bit LATIN-1 encoded string. | |
char * | dkenc_str_bits82utf8 (char *s) |
Convert 8-bit LATIN-1 encoded string to UTF-8 encoded string. | |
int | dkenc_bin_to_ra85 (char *dp, size_t ds, char *sp, size_t ss) |
Convert binary data to reverse ASCII-85 encoded string. | |
size_t | dkenc_ra85_to_bin (char *dp, size_t ds, char *sp, size_t ss) |
Convert reverse ASCII-85 encoded data to binary data. | |
size_t | dkenc_ra85string_to_bin (char *dp, size_t ds, char *sp) |
Convert reverse ASCII-85 encoded string to binary data. | |
int | dkenc_bin_to_a85 (char *dp, size_t ds, char *sp, size_t ss) |
Convert binary data to ASCII-85 encoded string. | |
size_t | dkenc_a85_to_bin (char *dp, size_t ds, char *sp, size_t ss) |
Convert ASCII-85 encoded data to binary data. | |
size_t | dkenc_a85string_to_bin (char *dp, size_t ds, char *sp) |
Convert ASCII-85 encoded string to binary data. | |
int | dkenc_bin_to_hex (char *dp, size_t ds, char *sp, size_t ss) |
Convert binary data to hex encoded string. | |
size_t | dkenc_hex_to_bin (char *dp, size_t ds, char *sp, size_t ss) |
Convert hex encoded data to binary data. | |
size_t | dkenc_hexstring_to_bin (char *dp, size_t ds, char *sp) |
Convert hex encoded string to binary data. | |
size_t | dkenc_size_bin_to_a85 (size_t sz) |
Calculate buffer size needed to convert binary data to ASCII85 or reverse ASCII85 string. | |
size_t | dkenc_size_a85_to_bin (size_t sz) |
Calculate buffer size needed to convert ASCII85 or reverse-ASCII85 encoded data to binary. | |
size_t | dkenc_size_a85string_to_bin (char *s) |
Calculate bufer size needed to convert an ASCII85 or reverse-ASCII85 encoded string to binary. | |
size_t | dkenc_size_bin_to_hex (size_t sz) |
Calculate buffer size needed to convert binary data to hexadecimal string. | |
size_t | dkenc_size_hex_to_bin (size_t sz) |
Calculate bufer size needed to convert a hex encoded string to binary. | |
size_t | dkenc_size_hexstring_to_bin (char *s) |
Calculate bufer size needed to convert a hex encoded string to binary. |
This module contains functions to change encodings.
The dkenc_ntohl() function group is intended as replacement for ntohl() and friends. On Windows systems these functions are in winsock2.dll which is an optional DLL typically not installed on standalone systems. To change byte order for data read from file we need replacement functions.
size_t dkenc_a85_to_bin | ( | char * | dp, | |
size_t | ds, | |||
char * | sp, | |||
size_t | ss | |||
) |
Convert ASCII-85 encoded data to binary data.
dp | Pointer to destination buffer. | |
ds | Destination buffer size in bytes. | |
sp | Pointer to source buffer. | |
ss | Source buffer size in bytes. |
size_t dkenc_a85string_to_bin | ( | char * | dp, | |
size_t | ds, | |||
char * | sp | |||
) |
Convert ASCII-85 encoded string to binary data.
dp | Pointer to destination buffer. | |
ds | Destination buffer size in bytes. | |
sp | Pointer to source string. |
int dkenc_bin_to_a85 | ( | char * | dp, | |
size_t | ds, | |||
char * | sp, | |||
size_t | ss | |||
) |
Convert binary data to ASCII-85 encoded string.
dp | Pointer to destination buffer. | |
ds | Destination buffer size in bytes. | |
sp | Pointer to source buffer. | |
ss | Source buffer size in bytes. |
int dkenc_bin_to_hex | ( | char * | dp, | |
size_t | ds, | |||
char * | sp, | |||
size_t | ss | |||
) |
Convert binary data to hex encoded string.
Uppercase characters are used for 'A', 'B', 'C', D', 'E' and 'F'.
dp | Pointer to destination buffer. | |
ds | Destination buffer size in bytes. | |
sp | Pointer to source buffer. | |
ss | Source buffer size in bytes. |
int dkenc_bin_to_ra85 | ( | char * | dp, | |
size_t | ds, | |||
char * | sp, | |||
size_t | ss | |||
) |
Convert binary data to reverse ASCII-85 encoded string.
dp | Pointer to destination buffer. | |
ds | Destination buffer size in bytes. | |
sp | Pointer to source buffer. | |
ss | Source buffer size in bytes. |
size_t dkenc_hex_to_bin | ( | char * | dp, | |
size_t | ds, | |||
char * | sp, | |||
size_t | ss | |||
) |
Convert hex encoded data to binary data.
Both upper- and lowercase characters can be used for 'a', 'b', 'c', 'd', 'e' and 'f'.
dp | Pointer to destination buffer. | |
ds | Destination buffer size in bytes. | |
sp | Pointer to source buffer. | |
ss | Source buffer size in bytes. |
size_t dkenc_hexstring_to_bin | ( | char * | dp, | |
size_t | ds, | |||
char * | sp | |||
) |
Convert hex encoded string to binary data.
dp | Pointer to destination buffer. | |
ds | Destination buffer size in bytes. | |
sp | Pointer to source string. |
unsigned long dkenc_htonl | ( | unsigned long | l | ) |
Convert long (32 bit integer) from host byte order to network byte order.
l | The long unsigned in host byte order. |
unsigned short dkenc_htons | ( | unsigned short | s | ) |
Convert short (16 bit integer) from host byte order to network byte order.
s | The unsigned short in host byte order. |
int dkenc_ipaddr_to_ul | ( | char * | s, | |
unsigned long * | u | |||
) |
Convert text IP address to unsigned long in host representation.
s | String containing the IP address in dotted decimal notation. | |
u | Pointer to unsigned long variable to receive the conversion result. |
unsigned long dkenc_ntohl | ( | unsigned long | l | ) |
Convert long (32 bit integer) from network byte order to host byte order.
l | Long unsigned in network byte order. |
unsigned short dkenc_ntohs | ( | unsigned short | s | ) |
Convert short (16 bit integer) from network byte order to host byte order.
s | The unsigned short number in network byte order. |
size_t dkenc_ra85_to_bin | ( | char * | dp, | |
size_t | ds, | |||
char * | sp, | |||
size_t | ss | |||
) |
Convert reverse ASCII-85 encoded data to binary data.
dp | Pointer to destination buffer. | |
ds | Destination buffer size in bytes. | |
sp | Pointer to source buffer. | |
ss | Source buffer size in bytes. |
size_t dkenc_ra85string_to_bin | ( | char * | dp, | |
size_t | ds, | |||
char * | sp | |||
) |
Convert reverse ASCII-85 encoded string to binary data.
dp | Pointer to destination buffer. | |
ds | Destination buffer size in bytes. | |
sp | Pointer to source string. |
size_t dkenc_size_a85_to_bin | ( | size_t | sz | ) |
Calculate buffer size needed to convert ASCII85 or reverse-ASCII85 encoded data to binary.
sz | Source data size. |
size_t dkenc_size_a85string_to_bin | ( | char * | s | ) |
Calculate bufer size needed to convert an ASCII85 or reverse-ASCII85 encoded string to binary.
s | The encoded string. |
size_t dkenc_size_bin_to_a85 | ( | size_t | sz | ) |
Calculate buffer size needed to convert binary data to ASCII85 or reverse ASCII85 string.
sz | Source data size. |
size_t dkenc_size_bin_to_hex | ( | size_t | sz | ) |
Calculate buffer size needed to convert binary data to hexadecimal string.
sz | Source data size. |
size_t dkenc_size_hex_to_bin | ( | size_t | sz | ) |
Calculate bufer size needed to convert a hex encoded string to binary.
s | The encoded string. |
size_t dkenc_size_hexstring_to_bin | ( | char * | s | ) |
Calculate bufer size needed to convert a hex encoded string to binary.
s | The encoded string. |
char* dkenc_str_bits82utf8 | ( | char * | s | ) |
Convert 8-bit LATIN-1 encoded string to UTF-8 encoded string.
The function returns a pointer to a new string in dynamically allocated memory. You must release the string after usage, call dk_delete().
s | The LATIN-1 encoded string. |
char* dkenc_str_utf82bits8 | ( | char * | s, | |
int * | p | |||
) |
Convert UTF-8 encoded string to 8-bit LATIN-1 encoded string.
The function returns a pointer to a new string in dynamically allocated memory. You must release the string after usage, call dk_delete().
s | UTF-8 encoded string. | |
p | Pointer to a variable to receive the error code (if any). |
Convert 32-bit character to UTF-8.
c | The character to convert. | |
u8p | Buffer to receive the UTF-8 encoded result. | |
u8l | Length of u8p. |
c | The 32-bit character. | |
u8p | Buffer to receive UTF-8 encoded result. | |
u8l | Length of u8l. |
Convert an UTF-8 encoded character into the appropriate 32 bit character.
ucp | Pointer to a variable for conversion result. | |
u8p | Pointer to buffer containing UTF-8 encoded data. | |
u8l | Number of bytes available in u8p. | |
u8u | Pointer to variable to store the number of bytes used from u8p. |
ucp | Pointer to variable for result. | |
u8p | Buffer containing UTF-8 encoded text. | |
u8l | Number of bytes in buffer. | |
u8u | Pointer to variable to receive number of bytes used. |