2 * Copyright (c) 2013 Stefano Sabatini
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #include "libavutil/avstring.h"
25 #include "libavutil/file.h"
27 static void print_sequence(const char *p, int l, int indent)
30 for (i = 0; i < l; i++)
31 printf("%02X", (uint8_t)p[i]);
32 printf("%*s", indent-l*2, "");
35 int main(int argc, char **argv)
38 char *filename = argv[1];
42 const uint8_t *p, *endp;
44 ret = av_file_map(filename, &file_buf, &file_buf_size, 0, NULL);
49 endp = file_buf + file_buf_size;
52 const uint8_t *p0 = p;
54 r = av_utf8_decode(&code, &p, endp, 0);
56 print_sequence(p0, l, 20);
57 if (code != UINT32_MAX) {
58 printf("%-10d 0x%-10X %-5d ", code, code, l);
60 if (*p0 == '\n') printf("\\n\n");
61 else printf ("%.*s\n", l, p0);
63 printf("invalid code range\n");
66 printf("invalid sequence\n");
70 av_file_unmap(file_buf, file_buf_size);