summaryrefslogtreecommitdiff
path: root/utf/inc/utf32.hh
blob: 2d3088eec7ef7f036063f71476b88d3dadd6499a (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
#ifndef UTF_UTF32_HH
#define UTF_UTF32_HH

#include "macros.hh"

#include <cstdint>
#include <string_view>

namespace utf {

/* Read one unicode codepoint from UTF-32 BigEndian encoded data if possible.
 * If successfull offset is incremented to point to next codepoint.
 * Will fail:
 * - not enough data is left in data given offset, returns NEED_MORE.
 * - data is not valid UTF-32, ie. outside valid ranges, returns INVALID.
 */
uint32_t HIDDEN read32be(std::string_view data, std::size_t& offset);

/* Read one unicode codepoint from UTF-32 LittleEndian encoded data if possible.
 * If successfull offset is incremented to point to next codepoint.
 * Will fail:
 * - not enough data is left in data given offset, returns NEED_MORE.
 * - data is not valid UTF-32, ie. outside valid ranges, returns INVALID.
 */
uint32_t HIDDEN read32le(std::string_view data, std::size_t& offset);

}  // namespace utf

#endif  // UTF_UTF32_HH