1#include <assert.h>
2#include <string>
3
4#define UASZ 64
5
6template<class T, int N>
7void copy_char_seq (T (&arr)[N], const T* src)
8{
9 size_t src_len = std::char_traits<T>::length(src);
10 assert(src_len < N);
11
12 std::char_traits<T>::copy(arr, src, src_len);
13 arr[src_len] = 0;
14}
15
16int main (int argc, char const *argv[])
17{
18 char16_t as16[UASZ];
19 char32_t as32[UASZ];
20 auto cs16_zero = (char16_t)0;
21 auto cs32_zero = (char32_t)0;
22 auto cs16 = u"hello world ྒྙྐ";
23 auto cs32 = U"hello world ྒྙྐ";
24 char16_t *s16 = (char16_t *)u"ﺸﺵۻ";
25 char32_t *s32 = (char32_t *)U"ЕЙРГЖО";
26 copy_char_seq(arr&: as16, src: s16);
27 copy_char_seq(arr&: as32, src: s32);
28 s32 = nullptr; // breakpoint1
29 s32 = (char32_t *)U"෴";
30 s16 = (char16_t *)u"色ハ匂ヘト散リヌルヲ";
31 copy_char_seq(arr&: as16, src: s16);
32 copy_char_seq(arr&: as32, src: s32);
33 s32 = nullptr; // breakpoint2
34 return 0;
35}
36

source code of lldb/test/API/lang/cpp/char1632_t/main.cpp