Search code examples
d

Convert dlang char/wchar to string/wstring


How do I convert a single char/wchar to a single-character string/wstring in d? I can't find anything online that doesn't talk about char* or wchar*.


Solution

  • As strings are just immutable(char)[], you can construct them like any other array with chars:

    char a = 'a';
    string s = [a];