toLowerCase

Produces the passed string in lowercase as per the supplied case mappings.

This function is @trusted to be able to cast the internal output char array to string. Appender does this with its data/opSlice methods.

@property inout(ElementEncodingType!A)[] opSlice() inout @trusted pure nothrow
{
     /* @trusted operation:
      * casting Unqual!T[] to inout(T)[]
      */
     return cast(typeof(return))(_data ? _data.arr : null);
}

So just do the same.

pure nothrow @trusted
toLowerCase

Parameters

name string

String to parse into lowercase.

caseMapping IRCServer.CaseMapping

Server case mapping; maps uppercase to lowercase characters.

Return Value

Type: auto

The passed name string with uppercase characters replaced as per the case mappings.

Examples

IRCServer.CaseMapping m = IRCServer.CaseMapping.rfc1459;

{
    immutable before = "ABCDEF";
    immutable lowercase = toLowerCase(before, m);
    assert((lowercase == "abcdef"), lowercase);
}
{
    immutable before = "123";
    immutable lowercase = toLowerCase(before, m);
    assert((lowercase == "123"), lowercase);
    assert(before is lowercase);
    assert(before.ptr == lowercase.ptr);
}
{
    immutable lowercase = toLowerCase("^[0v0]^", m);
    assert((lowercase == "~{0v0}~"), lowercase);
}
{
    immutable lowercase = toLowerCase(`A|\|`, m);
    assert((lowercase == "a|||"), lowercase);
}

m = IRCServer.caseMapping.ascii;

{
    immutable before = "^[0v0]^";
    immutable lowercase = toLowerCase(before, m);
    assert((lowercase == "^[0v0]^"), lowercase);
    assert(before is lowercase);
    assert(before.ptr == lowercase.ptr);
}
{
    immutable lowercase = toLowerCase(`A|\|`, m);
    assert((lowercase == `a|\|`), lowercase);
}

m = IRCServer.CaseMapping.strict_rfc1459;

{
    immutable lowercase = toLowerCase("^[0v0]^", m);
    assert((lowercase == "^{0v0}^"), lowercase);
}

Meta