1
/***************************************************************************
2
* fqterm, a terminal emulator for both BBS and *nix. *
3
* Copyright (C) 2008 fqterm development group. *
5
* This program is free software; you can redistribute it and/or modify *
6
* it under the terms of the GNU General Public License as published by *
7
* the Free Software Foundation; either version 2 of the License, or *
8
* (at your option) any later version. *
10
* This program is distributed in the hope that it will be useful, *
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13
* GNU General Public License for more details. *
15
* You should have received a copy of the GNU General Public License *
16
* along with this program; if not, write to the *
17
* Free Software Foundation, Inc., *
18
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. *
19
***************************************************************************/
21
#ifndef FQTERM_FQWCWIDTH_H
22
#define FQTERM_FQWCWIDTH_H
25
#define uint32_t unsigned __int32
26
#define uint16_t unsigned __int16
27
typedef wchar_t UTF16;
31
typedef uint16_t UTF16;
34
typedef char Verify_UTF16_Is_Two_Bytes[
35
(sizeof(UTF16) == 2)? 1 : -1];
39
//const uint16_t URC = 0xfffd; // the Unicode Replacement Character
40
// TODO_UTF16: 0xfffd is of width 2, which is not desired.
41
const uint16_t URC = '?'; // use '?' instead of the Unicode Replacement Character
43
const int MAX_CELLS_PER_CHAR = 2;
45
int get_str_width(uint32_t ucs);
46
int get_str_width(const uint32_t *pwcs, size_t n);
47
int get_str_width(const UTF16 *utf16_str, size_t n);
48
int get_str_width(const UTF16 *utf16_str, size_t n, int max_width, int &element_consumed);
50
// Move p to next code point in max_n UTF16 characters.
51
// Return the width of the current code point.
52
int mk_advance_one_code_point(const UTF16 **p, const UTF16 *end);
54
// Move p to next code point in max_n UTF16 characters.
56
int mk_advace_at_least_one_cell(const UTF16 **p, const UTF16 *end);
60
#endif // FQTERM_FQWCWIDTH_H