88#include  < string_view> 
99
1010#include  < m/utf/transcode.h> 
11+ #include  < m/utility/pointers.h> 
1112
1213#include  " convert.h" 
1314
@@ -73,6 +74,21 @@ namespace m
7374        utf::transcode (std::u8string_view{s}, str);
7475    }
7576
77+     constexpr  std::wstring
78+     to_wstring (m::not_null<char8_t  const *> ptr)
79+     {
80+         return  to_wstring (std::u8string_view (ptr));
81+     }
82+ 
83+     constexpr  std::optional<std::wstring>
84+     to_wstring (char8_t  const * ptr)
85+     {
86+         if  (ptr)
87+             return  to_wstring (m::not_null<char8_t  const *>(ptr));
88+ 
89+         return  std::nullopt ;
90+     }
91+ 
7692    constexpr  std::wstring
7793    to_wstring (std::u16string_view v)
7894    {
@@ -127,6 +143,21 @@ namespace m
127143        utf::transcode (std::u16string_view{s}, str);
128144    }
129145
146+     constexpr  std::wstring
147+     to_wstring (m::not_null<char16_t  const *> ptr)
148+     {
149+         return  to_wstring (std::u16string_view (ptr));
150+     }
151+ 
152+     constexpr  std::optional<std::wstring>
153+     to_wstring (char16_t  const * ptr)
154+     {
155+         if  (ptr)
156+             return  to_wstring (m::not_null<char16_t  const *>(ptr));
157+ 
158+         return  std::nullopt ;
159+     }
160+ 
130161    constexpr  std::wstring
131162    to_wstring (std::u32string_view v)
132163    {
@@ -181,6 +212,21 @@ namespace m
181212        utf::transcode (std::u32string_view{s}, str);
182213    }
183214
215+     constexpr  std::wstring
216+     to_wstring (m::not_null<char32_t  const *> ptr)
217+     {
218+         return  to_wstring (std::u32string_view (ptr));
219+     }
220+ 
221+     constexpr  std::optional<std::wstring>
222+     to_wstring (char32_t  const * ptr)
223+     {
224+         if  (ptr)
225+             return  to_wstring (m::not_null<char32_t  const *>(ptr));
226+ 
227+         return  std::nullopt ;
228+     }
229+ 
184230    constexpr  void 
185231    to_u8string (std::wstring_view v, std::u8string& str)
186232    {
@@ -195,6 +241,21 @@ namespace m
195241        return  str;
196242    }
197243
244+     constexpr  std::u8string
245+     to_u8string (m::not_null<wchar_t  const *> ptr)
246+     {
247+         return  to_u8string (std::wstring_view (ptr));
248+     }
249+ 
250+     constexpr  std::optional<std::u8string>
251+     to_u8string (wchar_t  const * ptr)
252+     {
253+         if  (ptr)
254+             return  to_u8string (m::not_null<wchar_t  const *>(ptr));
255+ 
256+         return  std::nullopt ;
257+     }
258+ 
198259    constexpr  void 
199260    to_u16string (std::wstring_view v, std::u16string& str)
200261    {
@@ -209,6 +270,21 @@ namespace m
209270        return  str;
210271    }
211272
273+     constexpr  std::u16string
274+     to_u16string (m::not_null<wchar_t  const *> ptr)
275+     {
276+         return  to_u16string (std::wstring_view (ptr));
277+     }
278+ 
279+     constexpr  std::optional<std::u16string>
280+     to_u16string (wchar_t  const * ptr)
281+     {
282+         if  (ptr)
283+             return  to_u16string (m::not_null<wchar_t  const *>(ptr));
284+ 
285+         return  std::nullopt ;
286+     }
287+ 
212288    // 
213289    //  to_u32string
214290    // 
@@ -226,4 +302,19 @@ namespace m
226302        return  str;
227303    }
228304
305+     constexpr  std::u32string
306+     to_u32string (m::not_null<wchar_t  const *> ptr)
307+     {
308+         return  to_u32string (std::wstring_view (ptr));
309+     }
310+ 
311+     constexpr  std::optional<std::u32string>
312+     to_u32string (wchar_t  const * ptr)
313+     {
314+         if  (ptr)
315+             return  to_u32string (m::not_null<wchar_t  const *>(ptr));
316+ 
317+         return  std::nullopt ;
318+     }
319+ 
229320} //  namespace m
0 commit comments