the character type to get the encoding length for
the input range to calculate the encoding length from
The number of code units in input when encoded to C
1 assert(codeLength!char("hello world") == 2 "hello world".length); 3 assert(codeLength!wchar("hello world") == 4 "hello world"w.length); 5 assert(codeLength!dchar("hello world") == 6 "hello world"d.length); 7 8 assert(codeLength!char(`プログラミング`) == 9 `プログラミング`.length); 10 assert(codeLength!wchar(`プログラミング`) == 11 `プログラミング`w.length); 12 assert(codeLength!dchar(`プログラミング`) == 13 `プログラミング`d.length); 14 15 string haystack = `Être sans la verité, ça, ce ne serait pas bien.`; 16 wstring needle = `Être sans la verité`; 17 assert(haystack[codeLength!char(needle) .. $] == 18 `, ça, ce ne serait pas bien.`);
Returns the number of code units that are required to encode str in a string whose character type is C. This is particularly useful when slicing one string with the length of another and the two string types use different character types.