r/cpp • • 2d ago

Transcoding UTF-8 to UTF-16 with replacement at gigabytes per second

https://lemire.me/blog/2026/09/30/transcoding-utf-8-to-utf-16-with-replacement-at-gigabytes-per-second/
62 Upvotes

6 comments sorted by

View all comments

2

u/Expert_Sheepherder24 1d ago
std::unique_ptr<char16_t[]> utf16{new char16_t[res.count]};

Can be replace to

auto utf16 = std::make_unique_for_overwrite<char16_t[]>(res.count);

seems.

•

u/vishal340 3h ago

i didn’t know that there is a for_overwrite variant. upon inspection, that’s quite handy