ELC in dev
ELC-lang
载入中...
搜索中...
未找到
elc::char_set::convert_impl 命名空间参考

函数

constexpr size_t decode_utf8 (char32_t *out, const char8_t *in, size_t in_size_max) noexcept
 
constexpr size_t get_decode_utf8_size (const char8_t *in) noexcept
 
constexpr size_t decode_utf16 (char32_t *out, const char16_t *in, size_t in_size_max) noexcept
 
constexpr size_t get_decode_utf16_size (const char16_t *in) noexcept
 
constexpr size_t encode_utf8 (char8_t *out, char32_t in) noexcept
 
constexpr size_t get_encode_utf8_size (char32_t in) noexcept
 
constexpr size_t encode_utf16 (char16_t *out, char32_t in) noexcept
 
constexpr size_t get_encode_utf16_size (char32_t in) noexcept
 

函数说明

◆ decode_utf16()

constexpr size_t elc::char_set::convert_impl::decode_utf16 ( char32_t *  out,
const char16_t *  in,
size_t  in_size_max 
)
inlineconstexprnoexcept

在文件 all_defs.cpp17069 行定义.

17069 {
17070 const char16_t code1 = *in++;
17071 if(code1 >= 0xD800 && code1 < 0xDC00){ /* surrogate pair */
17072 if(in_size_max < 2)
17073 return npos;
17074 const char16_t code2 = *in++;
17075 if(code2 >= 0xDC00 && code2 < 0xE000){
17076 *out = (code1 << 10) + code2 - 0x35FDC00;
17077 return 2;
17078 }
17079 return npos;
17080 }
17081 *out = code1;
17082 return 1;
17083 }

◆ decode_utf8()

constexpr size_t elc::char_set::convert_impl::decode_utf8 ( char32_t *  out,
const char8_t *  in,
size_t  in_size_max 
)
inlineconstexprnoexcept

在文件 all_defs.cpp16999 行定义.

16999 {
17000 push_and_disable_msvc_warning(26494);//未初始化警告diss
17001 char8_t code1, code2, code3, code4;
17003 code1 = *in++;
17004 if(code1 < 0x80){ /* 1-byte sequence */
17005 *out = code1;
17006 return 1;
17007 }
17008 elseif(code1 < 0xC2)
17009 return npos;
17010 elseif(code1 < 0xE0){ /* 2-byte sequence */
17011 if(in_size_max < 2)
17012 return npos;
17013 code2 = *in++;
17014 if((code2 & 0xC0) != 0x80)
17015 return npos;
17016 *out = (code1 << 6) + code2 - 0x3080;
17017 return 2;
17018 }
17019 elseif(code1 < 0xF0){ /* 3-byte sequence */
17020 if(in_size_max < 3)
17021 return npos;
17022 code2 = *in++;
17023 if((code2 & 0xC0) != 0x80)
17024 return npos;
17025 if(code1 == 0xE0 && code2 < 0xA0)
17026 return npos;
17027 code3 = *in++;
17028 if((code3 & 0xC0) != 0x80)
17029 return npos;
17030 *out = (code1 << 12) + (code2 << 6) + code3 - 0xE2080;
17031 return 3;
17032 }
17033 elseif(code1 < 0xF5){ /* 4-byte sequence */
17034 if(in_size_max < 4)
17035 return npos;
17036 code2 = *in++;
17037 if((code2 & 0xC0) != 0x80)
17038 return npos;
17039 if(code1 == 0xF0 && code2 < 0x90)
17040 return npos;
17041 if(code1 == 0xF4 && code2 >= 0x90)
17042 return npos;
17043 code3 = *in++;
17044 if((code3 & 0xC0) != 0x80)
17045 return npos;
17046 code4 = *in++;
17047 if((code4 & 0xC0) != 0x80)
17048 return npos;
17049 *out = (code1 << 18) + (code2 << 12) + (code3 << 6) + code4 - 0x3C82080;
17050 return 4;
17051 }
17052 else
17053 return npos;
17054 }
#define elseif
Definition all_defs.cpp:650
#define pop_msvc_warning()
Definition all_defs.cpp:478
#define push_and_disable_msvc_warning(...)
Definition all_defs.cpp:479
constexpr auto npos

◆ encode_utf16()

constexpr size_t elc::char_set::convert_impl::encode_utf16 ( char16_t *  out,
char32_t  in 
)
inlineconstexprnoexcept

在文件 all_defs.cpp17127 行定义.

17127 {
17128 if(in < 0x10000){
17129 *out++ = char16_t(in);
17130 return 1;
17131 }
17132 elseif(in < 0x110000){
17133 *out++ = char16_t((in >> 10) + 0xD7C0);
17134 *out++ = (in & 0x3FF) + 0xDC00;
17135 return 2;
17136 }
17137 return npos;
17138 }

◆ encode_utf8()

constexpr size_t elc::char_set::convert_impl::encode_utf8 ( char8_t *  out,
char32_t  in 
)
inlineconstexprnoexcept

在文件 all_defs.cpp17090 行定义.

17090 {
17091 if(in < 0x80){
17092 *out++ = (char8_t)in;
17093 return 1;
17094 }
17095 elseif(in < 0x800){
17096 *out++ = char8_t((in >> 6) + 0xC0);
17097 *out++ = char8_t((in & 0x3F) + 0x80);
17098 return 2;
17099 }
17100 elseif(in < 0x10000){
17101 *out++ = char8_t((in >> 12) + 0xE0);
17102 *out++ = ((in >> 6) & 0x3F) + 0x80;
17103 *out++ = (in & 0x3F) + 0x80;
17104 return 3;
17105 }
17106 elseif(in < 0x110000){
17107 *out++ = char8_t((in >> 18) + 0xF0);
17108 *out++ = ((in >> 12) & 0x3F) + 0x80;
17109 *out++ = ((in >> 6) & 0x3F) + 0x80;
17110 *out++ = (in & 0x3F) + 0x80;
17111 return 4;
17112 }
17113 return npos;
17114 }

◆ get_decode_utf16_size()

constexpr size_t elc::char_set::convert_impl::get_decode_utf16_size ( const char16_t *  in)
inlineconstexprnoexcept

在文件 all_defs.cpp17084 行定义.

17084 {
17085 if(*in >= 0xD800 && *in < 0xDC00) /* surrogate pair */
17086 return 2;
17087 else
17088 return 1;
17089 }

◆ get_decode_utf8_size()

constexpr size_t elc::char_set::convert_impl::get_decode_utf8_size ( const char8_t *  in)
inlineconstexprnoexcept

在文件 all_defs.cpp17055 行定义.

17055 {
17056 if(*in < 0x80) /* 1-byte sequence */
17057 return 1;
17058 elseif(*in < 0xC2)
17059 return npos;
17060 elseif(*in < 0xE0) /* 2-byte sequence */
17061 return 2;
17062 elseif(*in < 0xF0) /* 3-byte sequence */
17063 return 3;
17064 elseif(*in < 0xF5) /* 4-byte sequence */
17065 return 4;
17066 else
17067 return npos;
17068 }
else

◆ get_encode_utf16_size()

constexpr size_t elc::char_set::convert_impl::get_encode_utf16_size ( char32_t  in)
inlineconstexprnoexcept

在文件 all_defs.cpp17139 行定义.

17139 {
17140 if(in < 0x10000)
17141 return 1;
17142 elseif(in < 0x110000)
17143 return 2;
17144 else
17145 return npos;
17146 }

◆ get_encode_utf8_size()

constexpr size_t elc::char_set::convert_impl::get_encode_utf8_size ( char32_t  in)
inlineconstexprnoexcept

在文件 all_defs.cpp17115 行定义.

17115 {
17116 if(in < 0x80)
17117 return 1;
17118 elseif(in < 0x800)
17119 return 2;
17120 elseif(in < 0x10000)
17121 return 3;
17122 elseif(in < 0x110000)
17123 return 4;
17124 else
17125 return npos;
17126 }