summaryrefslogtreecommitdiff
path: root/Build/source/libs/xpdf/xpdf-src/xpdf/UTF8.h
blob: 1f29030096fc5770e92decf55cbb9bec5e55d054 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//========================================================================
//
// UTF8.h
//
// Copyright 2001-2017 Glyph & Cog, LLC
//
//========================================================================

#ifndef UTF8_H
#define UTF8_H

#include <aconf.h>

#include "gtypes.h"
#include "GString.h"
#include "CharTypes.h"

// Convert [u] to UTF-8 in [buf].  Returns the number of bytes written
// to [buf].  If [u] requires more then [bufSize] bytes in UTF-8,
// writes nothing and returns 0.
extern int mapUTF8(Unicode u, char *buf, int bufSize);

// Convert [u] to UCS-2BE in [buf].  Returns the number of bytes
// written to [buf].  If [u] requires more then [bufSize] bytes in
// UCS-2, writes nothing and returns 0.
extern int mapUCS2(Unicode u, char *buf, int bufSize);

// Parse one UTF-8 character from [s], starting at *[i].  Writes the
// character to *[u], updates *[i] to point to the next available byte
// in [s], and returns true.  At end of string: writes nothing to *[u]
// or *[i] and returns false.  For an invalid UTF-8 character: sets
// *[u] to the next byte, advances *[i] by one (to avoid infinite
// loops), and returns true.
extern GBool getUTF8(GString *s, int *i, Unicode *u);

// Same as getUTF8, but for UTF-16BE.
extern GBool getUTF16BE(GString *s, int *i, Unicode *u);

// Same as getUTF8, but for UTF-16LE.
extern GBool getUTF16LE(GString *s, int *i, Unicode *u);

#endif