1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QCODECMACROS_P_H
5#define QCODECMACROS_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists for the convenience
12// of other Qt classes. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18QT_BEGIN_NAMESPACE
19
20#define InRange(c, lower, upper) (((c) >= (lower)) && ((c) <= (upper)))
21#define IsLatin(c) ((c) <= 0x7F)
22#define IsByteInGb2312(c) (InRange((c), 0xA1, 0xFE))
23#define Is1stByte(c) (InRange((c), 0x81, 0xFE))
24#define Is2ndByteIn2Bytes(c) (InRange((c), 0x40, 0xFE) && (c) != 0x7F)
25#define Is2ndByteIn4Bytes(c) (InRange((c), 0x30, 0x39))
26#define Is2ndByte(c) (Is2ndByteIn2Bytes(c) || Is2ndByteIn4Bytes(c))
27#define Is3rdByte(c) (InRange((c), 0x81, 0xFE))
28#define Is4thByte(c) (InRange((c), 0x30, 0x39))
29
30#define qValidChar(u) ((u) ? (u) : static_cast<ushort>(QChar::ReplacementCharacter))
31
32/* User-defined areas: UDA 1: 0xAAA1 - 0xAFFE (564/0)
33 UDA 2: 0xF8A1 - 0xFEFE (658/0)
34 UDA 3: 0xA140 - 0xA7A0 (672/0) */
35#define IsUDA1(a, b) (InRange((a), 0xAA, 0xAF) && InRange((b), 0xA1, 0xFE))
36#define IsUDA2(a, b) (InRange((a), 0xF8, 0xFE) && InRange((b), 0xA1, 0xFE))
37#define IsUDA3(a, b) (InRange((a), 0xA1, 0xA7) && InRange((b), 0x40, 0xA0) && ((b) != 0x7F))
38
39#define IsSecondByteRange1(c) (InRange((c), 0x40, 0x7E))
40#define IsSecondByteRange2(c) (InRange((c), 0xA1, 0xFE))
41#define IsSecondByte(c) (IsSecondByteRange1(c) || IsSecondByteRange2(c))
42#define QValidChar(u) ((u) ? QChar((ushort)(u)) : QChar(QChar::ReplacementCharacter))
43
44#define IsKana(c) (((c) >= 0xa1) && ((c) <= 0xdf))
45
46#define IsEucChar(c) (((c) >= 0xa1) && ((c) <= 0xfe))
47#define IsCP949Char(c) (((c) >= 0x81) && ((c) <= 0xa0))
48
49#define IsJisChar(c) (((c) >= 0x21) && ((c) <= 0x7e))
50#define IsSjisUDC1(c) (((c) >= 0xf0) && ((c) <= 0xfc))
51#define IsSjisIBMVDCChar1(c) (((c) >= 0xfa) && ((c) <= 0xfc))
52
53#define IsSjisChar1(c) ((((c) >= 0x81) && ((c) <= 0x9f)) || (((c) >= 0xe0) && ((c) <= 0xfc)))
54#define IsSjisChar2(c) (((c) >= 0x40) && ((c) != 0x7f) && ((c) <= 0xfc))
55#define IsUserDefinedChar1(c) (((c) >= 0xf0) && ((c) <= 0xfc))
56
57#define IsTSCIIChar(c) (((c) >= 0x80) && ((c) <= 0xfd))
58
59QT_END_NAMESPACE
60
61#endif // QCODECMACROS_P_H
62

source code of qt5compat/src/core5/codecs/qcodecmacros_p.h