C++ Logo

sg16

Advanced search

Re: [SG16-Unicode] [ #embed_str ] Unicode Input

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 06 Nov 2019 14:20:24 -0800
On Wednesday, 6 November 2019 12:34:23 PST JeanHeyd Meneide wrote:
> It is not exactly trivial for #embed or #embed_str. #embed generates a
> brace-delimeted list of the bytes. It's as if the contents are directly
> replaced by:
>
> { 102, 111, 111 }
>
> You cannot "just append" a null terminator in there, so it would
> require a copy. If that's okay (copying things), then we can throw
> #embed_str out the window. As far as requiring bytes, you would need to
> generate a brace-delimeted list with all of the entries cast to the right
> type, because each of those entries is not trivially convertible to a
> std::byte: https://godbolt.org/z/NRkSfK

It's easy to add the terminating null with constexpr. And that function should
be provided. Similarly, it should be easy to concatenate such arrays.

It should be easy to import non-terminated byte data, null-terminated byte
data and UTF-8 text.

SG16 should also provide a way to constexpr-time convert UTF-8 text to UTF-16
or UTF-32

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel System Software Products

Received on 2019-11-06 23:28:30