---
name: "fmt_netstring"
section: "3"
platform: "linux"
package: "libowfat-dev"
version: "0.32-5"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/fmt_netstring"
---

# fmt\_netstring(3)

convert a memory buffer into a netstring

## NAME

fmt\_netstring - convert a memory buffer into a netstring

## SYNTAX

**#include \<libowfat/fmt.h\>**

size\_t **fmt\_netstring**(char \**dest*,const char \**source*,\
                       size\_t *len*);

## DESCRIPTION

fmt\_netstring creates a netstring from a raw memory buffer and returns the length.

fmt\_netstring does not append \\0.

If *dest* equals FMT\_LEN (i.e. is zero), fmt\_netstring returns the number of bytes it would have written.

## RETURN VALUE

fmt\_netstring returns the number of bytes written (or that would have been written, had the destination pointer not pointed to NULL).

If the input buffer is implausibly large, fmt\_netstring returns 0 instead.

## EXAMPLE

The raw memory buffer "foo" would become the netstring "3:foo,"

## SPEC

http://cr.yp.to/proto/netstrings.txt

## SEE ALSO

[scan\_netstring(3)](/scan_netstring/3.md)
