YSTest: CharacterProcessing.h 源文件

YSTest PreAlpha_b800_20170810 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

CharacterProcessing.h
浏览该文件的文档.
1 /*
2 © 2009-2015 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
28 #ifndef INC_CHRLib_CharacterProcessing_h_
29 #define INC_CHRLib_CharacterProcessing_h_ 1
30
31 #include "YModules.h"
32 #include YFM_CHRLib_CharacterMapping // for ystdex::is_null,
33 // ystdex::ntctslen ystdex::string_traits;
34 #include <cstdio> // for std::FILE;
35 #include <memory> // for std::move;
36
37 namespace CHRLib
38 {
39
41 using ystdex::uchar_t;
42
43
48 template<typename _tChar>
49 yconstfn bool
50 IsASCII(_tChar c)
51 {
52 return !(c & ~0x7F);
53 }
54
59 template<typename _tChar>
60 yconstfn char
61 ToASCII(_tChar c)
62 {
63 static_assert(std::is_integral<_tChar>(), "Invalid type found.");
64
65 return c & 0x7F;
66 }
67
68
70
71
73
75 YF_API ConversionResult
76 MBCToUC(char16_t&, const char*&, Encoding, ConversionState&& = {});
77 YF_API ConversionResult
78 MBCToUC(char16_t&, const char*&, const char*, Encoding, ConversionState&& = {});
79 inline PDefH(ConversionResult, MBCToUC, char16_t& uc, const char*& c,
80 Encoding enc, ConversionState& st)
81 ImplRet(MBCToUC(uc, c, enc, std::move(st)))
83
88 YF_API YB_NONNULL(2) ConversionResult
89 MBCToUC(char16_t&, std::FILE*, Encoding, ConversionState&& = {});
90 inline PDefH(ConversionResult, MBCToUC, char16_t& uc, std::FILE* fp, Encoding enc,
91 ConversionState& st)
92 ImplRet(MBCToUC(uc, fp, enc, std::move(st)))
94
95
100 YF_API ConversionResult
101 MBCToUC(const char*&, Encoding, ConversionState&& = {});
103 YF_API ConversionResult
104 MBCToUC(const char*&, const char*, Encoding, ConversionState&& = {});
105 inline PDefH(ConversionResult, MBCToUC, const char*& c, Encoding enc,
106 ConversionState& st)
107 ImplRet(MBCToUC(c, enc, std::move(st)))
109 inline PDefH(ConversionResult, MBCToUC, const char*& c, const char* e,
110 Encoding enc, ConversionState& st)
111 ImplRet(MBCToUC(c, e, enc, std::move(st)))
113
114 YF_API YB_NONNULL(1) ConversionResult
115 MBCToUC(std::FILE*, Encoding, ConversionState&& = {});
116 inline YB_NONNULL(1) PDefH(ConversionResult, MBCToUC, std::FILE* fp,
117 Encoding enc, ConversionState& st)
118 ImplRet(MBCToUC(fp, enc, std::move(st)))
120
121
128 YF_API YB_NONNULL(1) size_t
129 UCToMBC(char*, const char16_t&, Encoding);
131
132
134
135
137 template<typename _func, typename _tDst, typename _tSrc>
138 YB_NONNULL(2, 3) size_t
139 TranscodeWith(_func f, _tDst* d, const _tSrc* s)
140 {
141 yconstraint(d),
142 yconstraint(s);
143
144 const auto p(d);
145
146 f(d, s);
147 *d = _tDst();
148 return size_t(d - p);
149 }
150 template<typename _func, typename _tDst, typename _tSrc>
151 YB_NONNULL(2, 3, 4) size_t
152 TranscodeWith(_func f, _tDst* d, const _tSrc* s, const _tSrc* e)
153 {
154 yconstraint(d),
155 yconstraint(s),
156 yconstraint(e),
157 yconstraint(s <= e);
158
159 const auto p(d);
160
161 f(d, s, e);
162 return size_t(d - p);
163 }
165
167
168 template<typename _func, typename _tDst, typename _tSrc>
169 YB_NONNULL(2, 3) size_t
170 DecodeWith(_func f, _tDst* d, const _tSrc* s)
171 {
172 return CHRLib::TranscodeWith([&](_tDst*& dst, const _tSrc*& src){
173 while(!ystdex::is_null(*src) && f(*dst, src))
174 ++dst;
175 }, d, s);
176 }
177 template<typename _func, typename _tDst, typename _tSrc>
178 YB_NONNULL(2, 3, 4) size_t
179 DecodeWith(_func f, _tDst* d, const _tSrc* s, const _tSrc* e)
180 {
181 return CHRLib::TranscodeWith(
182 [&](_tDst*& dst, const _tSrc*& src, const _tSrc*& end){
183 while(!ystdex::is_null(*src) && f(*dst, src, end))
184 ++dst;
185 }, d, s, e);
186 }
187
188 template<typename _func, typename _tDst, typename _tSrc>
189 YB_NONNULL(2, 3) size_t
190 EncodeWith(_func f, _tDst* d, const _tSrc* s)
191 {
192 return CHRLib::TranscodeWith([&](char*& dst, const _tSrc*& src){
193 while(!ystdex::is_null(*src))
194 f(dst, src);
195 }, d, s);
196 }
197 template<typename _func, typename _tDst, typename _tSrc>
198 YB_NONNULL(2, 3, 4) size_t
199 EncodeWith(_func f, _tDst* d, const _tSrc* s, const _tSrc* e)
200 {
201 return CHRLib::TranscodeWith(
202 [&](_tDst*& dst, const _tSrc*& src, const _tSrc* end){
203 // TODO: Deferred. Use guard for encoding.
204 while(src < end)
205 f(dst, src, end);
206 }, d, s, e);
207 }
209
218
220 template<typename _func>
221 YB_NONNULL(2, 3) size_t
222 MBCSToUCS2(_func f, char16_t* d, const char* s)
223 {
224 return CHRLib::DecodeWith([&](char16_t& dc, const char*& src) -> bool{
225 return f(dc, src, ConversionState()) == ConversionResult::OK;
226 }, d, s);
227 }
228 template<typename _func>
229 YB_NONNULL(2, 3, 4) size_t
230 MBCSToUCS2(_func f, char16_t* d, const char* s, const char* e)
231 {
232 return CHRLib::DecodeWith(
233 [&](char16_t& dc, const char*& src, const char*& end) -> bool{
234 return f(dc, {src, end}, ConversionState()) == ConversionResult::OK;
235 }, d, s, e);
236 }
237 YF_API YB_FLATTEN YB_NONNULL(1, 2) size_t
238 MBCSToUCS2(char16_t*, const char*);
239 YF_API YB_NONNULL(1, 2) size_t
240 MBCSToUCS2(char16_t*, const char*, Encoding);
241 YF_API YB_FLATTEN YB_NONNULL(1, 2, 3) size_t
242 MBCSToUCS2(char16_t*, const char*, const char* e);
243 YF_API YB_NONNULL(1, 2, 3) size_t
244 MBCSToUCS2(char16_t*, const char*, const char* e, Encoding);
246
248
249 template<typename _func>
250 YB_NONNULL(2, 3) size_t
251 MBCSToUCS4(_func f, char32_t* d, const char* s)
252 {
253 return CHRLib::DecodeWith([&](char32_t& dc, const char*& src) -> bool{
254 // TODO: Necessary initialization?
255 char16_t c;
256
257 if(f(c, src, ConversionState()) == ConversionResult::OK)
258 {
259 dc = c;
260 return true;
261 }
262 return {};
263 }, d, s);
264 }
265 template<typename _func>
266 YB_NONNULL(2, 3, 4) size_t
267 MBCSToUCS4(_func f, char32_t* d, const char* s, const char* e)
268 {
269 return CHRLib::DecodeWith(
270 [&](char32_t& dc, const char*& src, const char*& end) -> bool{
271 // TODO: Necessary initialization?
272 char16_t c;
273
274 if(f(c, {src, end}, ConversionState()) == ConversionResult::OK)
275 {
276 dc = c;
277 return true;
278 }
279 return {};
280 }, d, s, e);
281 }
282 YF_API YB_FLATTEN YB_NONNULL(1, 2) size_t
283 MBCSToUCS4(char32_t*, const char*);
284 YF_API YB_NONNULL(1, 2) size_t
285 MBCSToUCS4(char32_t*, const char*, Encoding);
286 YF_API YB_FLATTEN YB_NONNULL(1, 2, 3) size_t
287 MBCSToUCS4(char32_t*, const char*, const char*);
288 YF_API YB_NONNULL(1, 2, 3) size_t
289 MBCSToUCS4(char32_t*, const char*, const char*, Encoding);
291
293
294
296 template<typename _func>
297 YB_NONNULL(2, 3) size_t
298 UCS2ToMBCS(_func f, char* d, const char16_t* s)
299 {
300 return CHRLib::EncodeWith([&](char*& dst, const char16_t*& src){
301 dst += f(dst, *src++);
302 }, d, s);
303 }
304 template<typename _func>
305 YB_NONNULL(2, 3, 4) size_t
306 UCS2ToMBCS(_func f, char* d, const char16_t* s, const char16_t* e)
307 {
308 return CHRLib::EncodeWith(
309 [&](char*& dst, const char16_t*& src, const char16_t*){
310 dst += f(dst, *src++);
311 }, d, s, e);
312 }
314 YF_API YB_FLATTEN YB_NONNULL(1, 2) size_t
315 UCS2ToMBCS(char*, const char16_t*);
316 YF_API YB_NONNULL(1, 2) size_t
317 UCS2ToMBCS(char*, const char16_t*, Encoding);
318 YF_API YB_FLATTEN YB_NONNULL(1, 2, 3) size_t
319 UCS2ToMBCS(char*, const char16_t*, const char16_t*);
320 YF_API YB_NONNULL(1, 2, 3) size_t
321 UCS2ToMBCS(char*, const char16_t*, const char16_t*, Encoding);
323
329 YF_API YB_NONNULL(1, 2) size_t
330 UCS2ToUCS4(char32_t*, const char16_t*);
331 YF_API YB_NONNULL(1, 2, 3) size_t
332 UCS2ToUCS4(char32_t*, const char16_t*, const char16_t*);
334
336
337
339 template<typename _func>
340 YB_NONNULL(2, 3) size_t
341 UCS4ToMBCS(_func f, char* d, const char32_t* s)
342 {
343 return CHRLib::EncodeWith([&](char*& dst, const char32_t*& src){
344 dst += f(dst, char16_t(*src++));
345 }, d, s);
346 }
347 template<typename _func>
348 YB_NONNULL(2, 3, 4) size_t
349 UCS4ToMBCS(_func f, char* d, const char32_t* s, const char32_t* e)
350 {
351 return CHRLib::EncodeWith(
352 [&](char*& dst, const char32_t*& src, const char32_t*){
353 dst += f(dst, char16_t(*src++));
354 }, d, s, e);
355 }
357 YF_API YB_FLATTEN YB_NONNULL(1, 2) size_t
358 UCS4ToMBCS(char*, const char32_t*);
359 YF_API YB_NONNULL(1, 2) size_t
360 UCS4ToMBCS(char*, const char32_t*, Encoding);
361 YF_API YB_FLATTEN YB_NONNULL(1, 2, 3) size_t
362 UCS4ToMBCS(char*, const char32_t*, const char32_t*);
363 YF_API YB_NONNULL(1, 2, 3) size_t
364 UCS4ToMBCS(char*, const char32_t*, const char32_t*, Encoding);
366
372 YF_API YB_NONNULL(1, 2) size_t
373 UCS4ToUCS2(char16_t*, const char32_t*);
374 YF_API YB_NONNULL(1, 2, 3) size_t
375 UCS4ToUCS2(char16_t*, const char32_t*, const char32_t*);
377
378
379
381
382 template<Encoding, Encoding>
383 struct DispatchTranscoding;
384
385 #define CHRLib_Impl_DispatchTranscoding(_vFrom, _vTo, _n) \
386 template<> \
387 struct DispatchTranscoding<CharSet::_vFrom, CharSet::_vTo> \
388 { \
389 template<typename... _tParams> \
390 static size_t \
391 Transcode(_tParams&&... args) \
392 { \
393 return _n(yforward(args)...); \
394 } \
395 };
396
397 CHRLib_Impl_DispatchTranscoding(Null, ISO_10646_UCS_2, MBCSToUCS2)
398
399 CHRLib_Impl_DispatchTranscoding(Null, ISO_10646_UCS_4, MBCSToUCS4)
400
401 CHRLib_Impl_DispatchTranscoding(ISO_10646_UCS_2, Null, UCS2ToMBCS)
402
403 CHRLib_Impl_DispatchTranscoding(ISO_10646_UCS_2, ISO_10646_UCS_4, UCS2ToUCS4)
404
405 CHRLib_Impl_DispatchTranscoding(ISO_10646_UCS_4, Null, UCS4ToMBCS)
406
407 CHRLib_Impl_DispatchTranscoding(ISO_10646_UCS_4, ISO_10646_UCS_2, UCS4ToUCS2)
408
409 #undef CHRLib_Impl_DispatchTranscoding
410
411
412 template<Encoding _vFrom, Encoding _vTo,
413 class _tDispatcher = DispatchTranscoding<_vFrom, _vTo>>
414 struct Transcoding
415 {
416 template<typename _tDst, typename _tChar, typename... _tParams>
417 static _tDst
418 MakeTranscoded(const _tChar* s, _tParams&&... args)
419 {
420 _tDst str(ystdex::ntctslen(s),
421 typename ystdex::string_traits<_tDst>::value_type());
422
423 str.resize(_tDispatcher::Transcode(&str[0], s, yforward(args)...));
424 return str;
425 }
426
427 template<typename _tDst, typename _type, typename... _tParams>
428 static _tDst
429 MakeViewTranscoded(_type sv, _tParams&&... args)
430 {
431 const auto s(sv.data());
432
433 yconstraint(s);
434
435 const auto l(sv.length());
436 _tDst str(l, typename ystdex::string_traits<_tDst>::value_type());
437
438 str.resize(_tDispatcher::Transcode(&str[0], s, s + l,
439 yforward(args)...));
440 return str;
441 }
442 };
443
444 template<Encoding _vFrom, class _tDispatcher>
445 struct Transcoding<_vFrom, CharSet::Null, _tDispatcher>
446 {
447 template<typename _tDst, typename _tChar,
448 typename... _tParams>
449 static _tDst
450 MakeTranscoded(const _tChar* s)
451 {
452 const auto w(FetchMaxCharWidth(CS_Default));
453 _tDst str(ystdex::ntctslen(s) * (w == 0 ? sizeof(ucsint_t) : w),
454 typename ystdex::string_traits<_tDst>::value_type());
455
456 str.resize(_tDispatcher::Transcode(&str[0], s));
457 return str;
458 }
459 template<typename _tDst, typename _tChar,
460 typename... _tParams>
461 static _tDst
462 MakeTranscoded(const _tChar* s, Encoding enc, _tParams&&... args)
463 {
464 const auto w(FetchMaxCharWidth(enc));
465 _tDst str(ystdex::ntctslen(s) * (w == 0 ? sizeof(ucsint_t) : w),
466 typename ystdex::string_traits<_tDst>::value_type());
467
468 str.resize(_tDispatcher::Transcode(&str[0], s, enc, yforward(args)...));
469 return str;
470 }
471
472 template<typename _tDst, typename _type,
473 typename... _tParams>
474 static _tDst
475 MakeViewTranscoded(_type sv)
476 {
477 const auto s(sv.data());
478
479 yconstraint(s);
480
481 const auto l(sv.length());
482 const auto w(FetchMaxCharWidth(CS_Default));
483 _tDst str(l * (w == 0 ? sizeof(ucsint_t) : w),
484 typename ystdex::string_traits<_tDst>::value_type());
485
486 str.resize(_tDispatcher::Transcode(&str[0], s, s + l));
487 return str;
488 }
489 template<typename _tDst, typename _type,
490 typename... _tParams>
491 static _tDst
492 MakeViewTranscoded(_type sv, Encoding enc, _tParams&&... args)
493 {
494 const auto s(sv.data());
495
496 yconstraint(s);
497
498 const auto l(sv.length());
499 const auto w(FetchMaxCharWidth(enc));
500 _tDst str(l * (w == 0 ? sizeof(ucsint_t) : w),
501 typename ystdex::string_traits<_tDst>::value_type());
502
503 str.resize(_tDispatcher::Transcode(&str[0], s, s + l, enc,
504 yforward(args)...));
505 return str;
506 }
507 };
509
510
517 #define CHRLib_Impl_Transcode(_vFrom, _vTo, ...) \
518 return Transcoding<CharSet::_vFrom, CharSet::_vTo> \
519 ::MakeTranscoded<_tDst>(__VA_ARGS__);
520 #define CHRLib_Impl_TranscodeView(_vFrom, _vTo, ...) \
521 return Transcoding<CharSet::_vFrom, CharSet::_vTo> \
522 ::MakeViewTranscoded<_tDst>(__VA_ARGS__);
523 #define CHRLib_Impl_MakeTrans(_n, _tSrcChar, _tDstChar, _vFrom, _vTo, _vDeEnc) \
524 template<class _tDst = std::basic_string<_tDstChar>, typename... _tParams> \
525 YB_NONNULL(1) _tDst \
526 Make##_n(const _tSrcChar* s, _tParams&&... args) \
527 { \
528 CHRLib_Impl_Transcode(_vFrom, _vTo, s, yforward(args)...); \
529 } \
530 template<class _tDst = std::basic_string<_tDstChar>, typename... _tParams> \
531 _tDst \
532 Make##_n(basic_string_view<_tSrcChar> sv, _tParams&&... args) \
533 { \
534 CHRLib_Impl_TranscodeView(_vFrom, _vTo, sv, yforward(args)...); \
535 }
536
538 CHRLib_Impl_MakeTrans(UCS2LE, char, char16_t, Null, ISO_10646_UCS_2, CS_Default)
540
544 template<class _tDst = std::basic_string<char16_t>>
545 inline _tDst
546 MakeUCS2LE(u16string_view sv, Encoding = CharSet::ISO_10646_UCS_2)
547 {
548 const auto s(sv.data());
549
550 yconstraint(s);
551 // FIXME: Correct conversion for encoding other than UCS-2LE.
552 return {s, sv.length()};
553 }
559 CHRLib_Impl_MakeTrans(UCS2LE, char32_t, char16_t, ISO_10646_UCS_4,
560 ISO_10646_UCS_2, CharSet::ISO_10646_UCS_4)
562
564
565 CHRLib_Impl_MakeTrans(UCS4LE, char, char32_t, Null, ISO_10646_UCS_4, CS_Default)
567
572 CHRLib_Impl_MakeTrans(UCS4LE, char16_t, char32_t, ISO_10646_UCS_2,
573 ISO_10646_UCS_4, CharSet::ISO_10646_UCS_2)
575
579 template<class _tDst = std::basic_string<char32_t>>
580 inline _tDst
581 MakeUCS4LE(u32string_view sv, Encoding = CharSet::ISO_10646_UCS_4)
582 {
583 const auto s(sv.data());
584
585 yconstraint(s);
586 // FIXME: Correct conversion for encoding other than UCS-4LE.
587 return {s, sv.length()};
588 }
589
591
593 template<class _tDst = std::string>
595 inline YB_NONNULL(1) _tDst
596 MakeMBCS(const char* s, Encoding enc)
597 {
598 return enc = CS_Default ? MakeMBCS<_tDst>(s)
599 : MakeMBCS<_tDst>(MakeUCS2LE(s, CS_Default), enc);
600 }
601 template<class _tDst = std::string>
602 inline _tDst
603 MakeMBCS(string_view sv, Encoding enc)
604 {
605 return enc = CS_Default ? MakeMBCS<_tDst>(sv)
606 : MakeMBCS<_tDst>(MakeUCS2LE(sv, CS_Default), enc);
607 }
609
611 CHRLib_Impl_MakeTrans(MBCS, char16_t, char, ISO_10646_UCS_2, Null, CS_Default)
613
615 CHRLib_Impl_MakeTrans(MBCS, char32_t, char, ISO_10646_UCS_4, Null, CS_Default)
617
618 #undef CHRLib_Impl_MakeTrans
619 #undef CHRLib_Impl_Transcode
620 #undef CHRLib_Impl_TranscodeView
621
622
623 } // namespace CHRLib;
624
625 #endif
626
CHRLib::Transcoding< _vFrom, CharSet::Null, _tDispatcher >::MakeViewTranscoded
static _tDst MakeViewTranscoded(_type sv, Encoding enc, _tParams &&...args)
Definition: CharacterProcessing.h:492
CHRLib::MBCSToUCS4
size_t MBCSToUCS4(char32_t *d, const char *s)
Definition: CharacterProcessing.cpp:166
CHRLib::MBCSToUCS2
size_t MBCSToUCS2(char16_t *d, const char *s)
Definition: CharacterProcessing.cpp:133
CHRLib::CharSet::ISO_10646_UCS_2
yconstexpr const Encoding ISO_10646_UCS_2(csUnicode)
ystdex::u32string_view
basic_string_view< char32_t > u32string_view
Definition: string_view.hpp:417
CHRLib::UCS2ToUCS4
size_t UCS2ToUCS4(char32_t *d, const char16_t *s)
Definition: CharacterProcessing.cpp:234
NPL::dst
YF_API const char src const string const char * dst
Definition: Dependency.h:95
yconstfn
#define yconstfn
指定编译时常量函数。
Definition: ydef.h:680
CHRLib::PDefH
PDefH(char16_t, FetchBiCharBE, const char *c_ptr) ImplRet(yconstraint(c_ptr)
取 c_ptr 指向的大端序双字节字符。
CHRLib::MBCToUC
MBCToUC
Definition: CharacterProcessing.h:109
CHRLib::DispatchTranscoding
Definition: CharacterProcessing.h:383
CHRLib::Transcoding::MakeViewTranscoded
static _tDst MakeViewTranscoded(_type sv, _tParams &&...args)
Definition: CharacterProcessing.h:429
ystdex::u16string_view
basic_string_view< char16_t > u16string_view
Definition: string_view.hpp:416
CHRLib::f
f(d, s)
CHRLib::UCS4ToMBCS
size_t UCS4ToMBCS(char *d, const char32_t *s)
Definition: CharacterProcessing.cpp:254
CHRLib::MakeMBCS
_tDst MakeMBCS(string_view sv, Encoding enc)
Definition: CharacterProcessing.h:603
CHRLib::UCToMBC
size_t UCToMBC(char *d, const char16_t &s, Encoding enc)
Definition: CharacterProcessing.cpp:120
CHRLib::FetchMaxCharWidth
YF_API YB_STATELESS size_t FetchMaxCharWidth(Encoding)
取指定编码的最大字符宽度。
Definition: chrmap.cpp:59
ystdex::ntctslen
size_t ntctslen(const _tChar *s)
计算简单 NTCTS 长度。
Definition: cstring.h:456
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
CHRLib::CharSet::ISO_10646_UCS_4
yconstexpr const Encoding ISO_10646_UCS_4(csUCS4)
CHRLib_Impl_DispatchTranscoding
#define CHRLib_Impl_DispatchTranscoding(_vFrom, _vTo, _n)
Definition: CharacterProcessing.h:385
CHRLib::Transcoding< _vFrom, CharSet::Null, _tDispatcher >::MakeTranscoded
static _tDst MakeTranscoded(const _tChar *s, Encoding enc, _tParams &&...args)
Definition: CharacterProcessing.h:462
CHRLib::ToASCII
yconstfn char ToASCII(_tChar c)
任意整数类型字符转换为 ASCII 取值范围兼容的字符。
Definition: CharacterProcessing.h:61
ystdex::cpp2011::end
_type * end(_type(&&array)[_vN])
Definition: range.hpp:54
YB_FLATTEN
#define YB_FLATTEN
标记函数尽可能内联定义内的调用。
Definition: ydef.h:477
CHRLib::Transcoding< _vFrom, CharSet::Null, _tDispatcher >::MakeTranscoded
static _tDst MakeTranscoded(const _tChar *s)
Definition: CharacterProcessing.h:450
CHRLib::YB_NONNULL
YB_NONNULL(1) PDefH(ConversionResult
转换指定编码的多字节字符串为指定类型的 UCS-2 字符串。
YSLib::Drawing::w
The boundary is out of the const Rect SDst w
Definition: YDraw.h:127
CHRLib_Impl_MakeTrans
#define CHRLib_Impl_MakeTrans(_n, _tSrcChar, _tDstChar, _vFrom, _vTo, _vDeEnc)
Definition: CharacterProcessing.h:523
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:140
CHRLib::UCS2ToMBCS
size_t UCS2ToMBCS(char *d, const char16_t *s)
Definition: CharacterProcessing.cpp:203
CHRLib::fp
std::FILE ConversionState fp
Definition: CharacterProcessing.h:92
CHRLib::ImplRet
const char *c_ptr ImplRet(yconstraint(c_ptr), char16_t((c_ptr[1]<< CHAR_BIT)|*c_ptr)) enum class ConversionResult
编码转换结果。
Definition: CharacterMapping.h:84
YModules.h
YF_API
#define YF_API
Definition: Platform.h:56
CHRLib::MakeUCS2LE
_tDst MakeUCS2LE(basic_string_view< char > sv, _tParams &&...args)
Definition: CharacterProcessing.h:538
CHRLib::enc
enc
Definition: CharacterProcessing.h:81
CHRLib::IsASCII
yconstfn bool IsASCII(_tChar c)
判断整数类型字符在 ASCII 字符取值范围内。
Definition: CharacterProcessing.h:50
CHRLib::ConversionState
编码转换状态。
Definition: CharacterMapping.h:106
CHRLib::e
const char const char * e
Definition: CharacterProcessing.h:109
CHRLib::Encoding
std::FILE Encoding
Definition: CharacterProcessing.h:89
CHRLib
Definition: CharacterDefinition.h:38
std
Definition: memory.hpp:1183
CHRLib::CS_Default
yconstexpr const Encoding CS_Default(CharSet::UTF_8)
默认字符编码。
CHRLib::CharSet::Encoding
Encoding
字符流编码标识。
Definition: Encoding.h:58
platform::containers::basic_string
std::basic_string< _tChar, _tTraits, _tAlloc > basic_string
满足 ISO C++03 std::basic_string 但不保证满足 ISO C++11 的实现。
Definition: Container.h:98
YSLib::Text::str
const char const char * str
Definition: TextFile.h:81
CHRLib::c
c
Definition: CharacterProcessing.h:81
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:995
CHRLib::Transcoding
Definition: CharacterProcessing.h:414
CHRLib::UCS4ToUCS2
size_t UCS4ToUCS2(char16_t *d, const char32_t *s)
Definition: CharacterProcessing.cpp:285
CHRLib::char16_t
char16_t((*c_ptr<< CHAR_BIT)|c_ptr[1])) inline PDefH(char16_t
取 c_ptr 指向的小端序双字节字符。
CHRLib::d
_tDst * d
Definition: CharacterProcessing.h:139
CHRLib::Transcoding::MakeTranscoded
static _tDst MakeTranscoded(const _tChar *s, _tParams &&...args)
Definition: CharacterProcessing.h:418
YSLib::Drawing::char32_t
tr TextRegion &tr char32_t
Definition: TextLayout.h:92
ystdex::string_traits::value_type
remove_rcv_t< decltype(std::declval< string_type >()[0])> value_type
Definition: string.hpp:58
yconstraint
#define yconstraint(_expr)
约束：接口语义。
Definition: cassert.h:88
CHRLib::MakeUCS4LE
_tDst MakeUCS4LE(basic_string_view< char > sv, _tParams &&...args)
Definition: CharacterProcessing.h:565
CHRLib::size_t
return size_t(d-p)
ystdex::is_null
bool is_null(_tChar c)
使用 std::char_traits::eq 判断是否为空字符。
Definition: cstring.h:127
ystdex::uchar_t
cond_t< is_trivially_replaceable< wchar_t, char16_t >, char16_t, cond_t< is_trivially_replaceable< wchar_t, char32_t >, char32_t, void >> uchar_t
指定和 wchar_t 互相替换存储的非 char 内建字符类型。
Definition: cstring.h:118
CHRLib::ucsint_t
std::char_traits< char32_t >::int_type ucsint_t
UCS 整数类型。
Definition: CharacterDefinition.h:47
ystdex::string_view
basic_string_view< char > string_view
Definition: string_view.hpp:415
CHRLib::Transcoding< _vFrom, CharSet::Null, _tDispatcher >::MakeViewTranscoded
static _tDst MakeViewTranscoded(_type sv)
Definition: CharacterProcessing.h:475
CHRLib::p
const auto p(d)