µGFX
2.9
version 2.9
mf_encoding.h
1
/*
2
* This file is subject to the terms of the GFX License. If a copy of
3
* the license was not distributed with this file, you can obtain one at:
4
*
5
* http://ugfx.io/license.html
6
*/
7
8
/* Simple UTF-8 decoder. Also implements the much simpler ASCII and UTF16
9
* input encodings.
10
*/
11
12
#ifndef _MF_ENCODING_H_
13
#define _MF_ENCODING_H_
14
15
#include "mf_config.h"
16
#ifndef MF_NO_STDINT_H
17
#include <stdint.h>
18
#endif
19
20
/* Type used to represent characters internally. */
21
#if MF_ENCODING == MF_ENCODING_ASCII
22
typedef
char
mf_char;
23
#define MFCHAR2UINT16(c) ((gU16)(gU8)(c))
24
#else
25
typedef
gU16 mf_char;
26
#define MFCHAR2UINT16(c) (c)
27
#endif
28
29
/* Type used to represent input strings. */
30
#if MF_ENCODING == MF_ENCODING_ASCII
31
typedef
const
char
* mf_str;
32
#elif MF_ENCODING == MF_ENCODING_UTF8
33
typedef
const
char
* mf_str;
34
#elif MF_ENCODING == MF_ENCODING_UTF16
35
typedef
const
gU16 * mf_str;
36
#elif MF_ENCODING == MF_ENCODING_WCHAR
37
#include <stddef.h>
38
typedef
const
wchar_t
* mf_str;
39
#endif
40
41
/* Returns the next character in the string and advances the pointer.
42
* When the string ends, returns 0 and leaves the pointer at the 0 byte.
43
*
44
* str: Pointer to variable holding current location in string.
45
* Initialize it to the start of the string.
46
*
47
* Returns: The next character, as unicode codepoint.
48
*/
49
MF_EXTERN mf_char mf_getchar(mf_str *str);
50
51
/* Moves back the pointer to the beginning of the previous character.
52
* Be careful not to go beyond the start of the string.
53
*/
54
MF_EXTERN
void
mf_rewind(mf_str *str);
55
56
#endif
Users
joel
Documents
projects
ugfx
library_v2
src
gdisp
mcufont
mf_encoding.h
Generated on Thu Aug 19 2021 13:46:13 for µGFX by
1.9.1