add range-based advancing encode funcs
parent
61ed0ce71f
commit
daea42666e
|
@ -818,6 +818,15 @@ namespace utf {
|
|||
return n;
|
||||
}
|
||||
|
||||
template<typename R>
|
||||
inline std::size_t encode_u8(R &sink, u32string_range &r) {
|
||||
std::size_t n = 0;
|
||||
if (!r.empty() && (n = utf::encode_u8(sink, r.front()))) {
|
||||
r.pop_front();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/* @brief Encode a UTF-32 code point into UTF-16.
|
||||
*
|
||||
* The values are written in `sink` which is an ostd::output_range_tag.
|
||||
|
@ -840,6 +849,15 @@ namespace utf {
|
|||
return n;
|
||||
}
|
||||
|
||||
template<typename R>
|
||||
inline std::size_t encode_u16(R &sink, u32string_range &r) {
|
||||
std::size_t n = 0;
|
||||
if (!r.empty() && (n = utf::encode_u16(sink, r.front()))) {
|
||||
r.pop_front();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/* @brief Encode a UTF-32 code point into a wide Unicode char/sequence.
|
||||
*
|
||||
* The value(s) are written in `sink` which is an ostd::output_range_tag.
|
||||
|
@ -882,6 +900,15 @@ namespace utf {
|
|||
return n;
|
||||
}
|
||||
|
||||
template<typename R>
|
||||
inline std::size_t encode_uw(R &sink, u32string_range &r) {
|
||||
std::size_t n = 0;
|
||||
if (!r.empty() && (n = utf::encode_uw(sink, r.front()))) {
|
||||
r.pop_front();
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/* @brief Get the number of Unicode code points in a string.
|
||||
*
|
||||
* This function keeps reading Unicode code points while it can and
|
||||
|
|
Loading…
Reference in New Issue