summaryrefslogtreecommitdiff
path: root/bittorrent/mbtstr/src/fprint.c
blob: d0ee30970945b0ceb4fbbdf53d1a4a0d5cfba17a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <complex.h>
#include <ctype.h>
#include <stdbool.h>

#include "mbtstr/utils.h"
#include "mbtstr/view.h"

void mbt_cview_fprint(struct mbt_cview view, FILE *stream)
{
    for (size_t i = 0; i < view.size; i++)
    {
        if (isprint(view.data[i]))
            fputc(view.data[i], stream);
        else
            fprintf(stream, "U+%04X", (view.data[i] + 256) % 256);
    }
}