fmt.h File Reference

String formatting API. More...

Detailed Description

String formatting API.

Author
Kaspar Schleiser kaspa.nosp@m.r@sc.nosp@m.hleis.nosp@m.er.d.nosp@m.e

Definition in file fmt.h.

#include <stdint.h>
#include <stddef.h>
+ Include dependency graph for fmt.h:

Go to the source code of this file.

Macros

#define FMT_USE_MEMMOVE   (1)
 use memmove() or internal implementation
 

Functions

size_t fmt_byte_hex (char *out, uint8_t byte)
 Format a byte value as hex. More...
 
size_t fmt_bytes_hex_reverse (char *out, const uint8_t *ptr, size_t n)
 Formats a sequence of bytes as hex bytes, starting with the last byte. More...
 
size_t fmt_u32_hex (char *out, uint32_t val)
 Convert a uint32 value to hex string. More...
 
size_t fmt_u64_hex (char *out, uint64_t val)
 Convert a uint64 value to hex string. More...
 
size_t fmt_u32_dec (char *out, uint32_t val)
 Convert a uint32 value to decimal string. More...
 
size_t fmt_u64_dec (char *out, uint64_t val)
 Convert a uint64 value to decimal string. More...
 
size_t fmt_u16_dec (char *out, uint16_t val)
 Convert a uint16 value to decimal string. More...
 
size_t fmt_s32_dec (char *out, int32_t val)
 Convert a int32 value to decimal string. More...
 
size_t fmt_s16_dec (char *out, int16_t val)
 Convert a int16 value to decimal string. More...
 
size_t fmt_s16_dfp (char *out, int16_t val, unsigned fp_digits)
 Convert 16-bit fixed point number to a decimal string. More...
 
size_t fmt_s32_dfp (char *out, int32_t val, unsigned fp_digits)
 Convert 32-bit fixed point number to a decimal string. More...
 
size_t fmt_float (char *out, float f, unsigned precision)
 Format float to string. More...
 
size_t fmt_strlen (const char *str)
 Count characters until '\0' (exclusive) in str. More...
 
size_t fmt_str (char *out, const char *str)
 Copy null-terminated string (excluding terminating \0) More...
 
uint32_t scn_u32_dec (const char *str, size_t n)
 Convert digits to uint32. More...
 
void print (const char *s, size_t n)
 Print string to stdout. More...
 
void print_u32_dec (uint32_t val)
 Print uint32 value to stdout. More...
 
void print_s32_dec (int32_t val)
 Print int32 value to stdout. More...
 
void print_byte_hex (uint8_t byte)
 Print byte value as hex to stdout. More...
 
void print_u32_hex (uint32_t val)
 Print uint32 value as hex to stdout. More...
 
void print_u64_hex (uint64_t val)
 Print uint64 value as hex to stdout. More...
 
void print_u64_dec (uint64_t val)
 Print uint64 value as decimal to stdout. More...
 
void print_float (float f, unsigned precision)
 Print float value. More...
 
void print_str (const char *str)
 Print null-terminated string to stdout. More...
 
size_t fmt_lpad (char *str, size_t in_len, size_t pad_len, char pad_char)
 Pad string to the left. More...