1 #include <wchar.h> 2 3 /* collate only by code points */ 4 size_t wcsxfrm(wchar_t *restrict dest, const wchar_t *restrict src, size_t n) 5 { 6 size_t l = wcslen(src); 7 if (l >= n) { 8 wmemcpy(dest, src, n-1); 9 dest[n-1] = 0; 10 } else wcscpy(dest, src); 11 return l; 12 } 13