[SG16-Unicode] std::byte based I/O library

Lyberta lyberta at lyberta.net
Thu Feb 7 12:41:00 CET 2019


Corentin:
> 1/  Text _is_ bytes. Unicode specifies BOM and little/big endian versions
> so I think prepending a bom ( should you want to ) and byte-swapping can be
> done along transcoding

Maybe separate BOM handling into a format state of the stream. Consider
this:

enum class std::bom_handling
{
	none, ///< Do not read or write BOM.
	not_utf8, ///< Read and write BOM only in UTf-16 and UTF-32.
	all ///< Read and write BOM in all 3 encoding forms.
};

BinaryOutputStream& stream;
stream.GetFormat().SetBOMHandling(std::bom_handling::all);

This feels like a more elegant design because it separates concerns better.

> 
> 3/ stream don't have an explicit encoding ( or locale, for that matter ),
> but they might expect one - think for example about writing to stdout.

stdout is a special case and we have a way to handle it - execution
character set. The only problem is that in order to go from Unicode to
ECS right now you'd need to use std::codecvt which is a horrible mess.

Still, there are some utilities that treat stdin/stdout as a stream of
raw bytes so it doesn't always represent a text stream.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
Url : http://www.open-std.org/pipermail/unicode/attachments/20190207/7cf2893b/attachment.bin 


More information about the Unicode mailing list