1 | // Copyright (C) 2016 The Qt Company Ltd. |
2 | // Copyright (C) 2018 Intel Corporation. |
3 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
4 | |
5 | #include "qutfcodec_p.h" |
6 | #include "qlist.h" |
7 | #include "qendian.h" |
8 | #include "qchar.h" |
9 | |
10 | #include "private/qsimd_p.h" |
11 | #include "private/qstringiterator_p.h" |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | #if QT_CONFIG(textcodec) |
16 | |
17 | QUtf8Codec::~QUtf8Codec() |
18 | { |
19 | } |
20 | |
21 | QByteArray QUtf8Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const |
22 | { |
23 | ConverterState s(QStringConverter::Flag::Stateless); |
24 | if (!state) |
25 | state = &s; |
26 | return QUtf8::convertFromUnicode(in: QStringView(uc, len), state); |
27 | } |
28 | |
29 | void QUtf8Codec::convertToUnicode(QString *target, const char *chars, int len, ConverterState *state) const |
30 | { |
31 | ConverterState s(QStringConverter::Flag::Stateless); |
32 | if (!state) |
33 | state = &s; |
34 | *target += QUtf8::convertToUnicode(in: QByteArrayView(chars, len), state); |
35 | } |
36 | |
37 | QString QUtf8Codec::convertToUnicode(const char *chars, int len, ConverterState *state) const |
38 | { |
39 | ConverterState s(QStringConverter::Flag::Stateless); |
40 | if (!state) |
41 | state = &s; |
42 | return QUtf8::convertToUnicode(in: QByteArrayView(chars, len), state); |
43 | } |
44 | |
45 | QByteArray QUtf8Codec::name() const |
46 | { |
47 | return "UTF-8" ; |
48 | } |
49 | |
50 | int QUtf8Codec::mibEnum() const |
51 | { |
52 | return 106; |
53 | } |
54 | |
55 | QUtf16Codec::~QUtf16Codec() |
56 | { |
57 | } |
58 | |
59 | QByteArray QUtf16Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const |
60 | { |
61 | ConverterState s(QStringConverter::Flag::Stateless); |
62 | if (!state) |
63 | state = &s; |
64 | return QUtf16::convertFromUnicode(QStringView(uc, len), state, e); |
65 | } |
66 | |
67 | QString QUtf16Codec::convertToUnicode(const char *chars, int len, ConverterState *state) const |
68 | { |
69 | ConverterState s(QStringConverter::Flag::Stateless); |
70 | if (!state) |
71 | state = &s; |
72 | return QUtf16::convertToUnicode(QByteArrayView(chars, len), state, e); |
73 | } |
74 | |
75 | int QUtf16Codec::mibEnum() const |
76 | { |
77 | return 1015; |
78 | } |
79 | |
80 | QByteArray QUtf16Codec::name() const |
81 | { |
82 | return "UTF-16" ; |
83 | } |
84 | |
85 | QList<QByteArray> QUtf16Codec::aliases() const |
86 | { |
87 | return QList<QByteArray>(); |
88 | } |
89 | |
90 | int QUtf16BECodec::mibEnum() const |
91 | { |
92 | return 1013; |
93 | } |
94 | |
95 | QByteArray QUtf16BECodec::name() const |
96 | { |
97 | return "UTF-16BE" ; |
98 | } |
99 | |
100 | QList<QByteArray> QUtf16BECodec::aliases() const |
101 | { |
102 | QList<QByteArray> list; |
103 | return list; |
104 | } |
105 | |
106 | int QUtf16LECodec::mibEnum() const |
107 | { |
108 | return 1014; |
109 | } |
110 | |
111 | QByteArray QUtf16LECodec::name() const |
112 | { |
113 | return "UTF-16LE" ; |
114 | } |
115 | |
116 | QList<QByteArray> QUtf16LECodec::aliases() const |
117 | { |
118 | QList<QByteArray> list; |
119 | return list; |
120 | } |
121 | |
122 | QUtf32Codec::~QUtf32Codec() |
123 | { |
124 | } |
125 | |
126 | QByteArray QUtf32Codec::convertFromUnicode(const QChar *uc, int len, ConverterState *state) const |
127 | { |
128 | ConverterState s(QStringConverter::Flag::Stateless); |
129 | if (!state) |
130 | state = &s; |
131 | return QUtf32::convertFromUnicode(QStringView(uc, len), state, e); |
132 | } |
133 | |
134 | QString QUtf32Codec::convertToUnicode(const char *chars, int len, ConverterState *state) const |
135 | { |
136 | ConverterState s(QStringConverter::Flag::Stateless); |
137 | if (!state) |
138 | state = &s; |
139 | return QUtf32::convertToUnicode(QByteArrayView(chars, len), state, e); |
140 | } |
141 | |
142 | int QUtf32Codec::mibEnum() const |
143 | { |
144 | return 1017; |
145 | } |
146 | |
147 | QByteArray QUtf32Codec::name() const |
148 | { |
149 | return "UTF-32" ; |
150 | } |
151 | |
152 | QList<QByteArray> QUtf32Codec::aliases() const |
153 | { |
154 | QList<QByteArray> list; |
155 | return list; |
156 | } |
157 | |
158 | int QUtf32BECodec::mibEnum() const |
159 | { |
160 | return 1018; |
161 | } |
162 | |
163 | QByteArray QUtf32BECodec::name() const |
164 | { |
165 | return "UTF-32BE" ; |
166 | } |
167 | |
168 | QList<QByteArray> QUtf32BECodec::aliases() const |
169 | { |
170 | QList<QByteArray> list; |
171 | return list; |
172 | } |
173 | |
174 | int QUtf32LECodec::mibEnum() const |
175 | { |
176 | return 1019; |
177 | } |
178 | |
179 | QByteArray QUtf32LECodec::name() const |
180 | { |
181 | return "UTF-32LE" ; |
182 | } |
183 | |
184 | QList<QByteArray> QUtf32LECodec::aliases() const |
185 | { |
186 | QList<QByteArray> list; |
187 | return list; |
188 | } |
189 | |
190 | #endif // textcodec |
191 | |
192 | QT_END_NAMESPACE |
193 | |