Decodes an IRCv3 tag string, replacing some characters.

IRCv3 tags need to be free of spaces, so by necessity they're encoded into \s. Likewise; since tags are separated by semicolons, semicolons in tag string are encoded into \:, and literal backslashes \\.

private public pure @safe nothrow
const string line


line string

Original line to decode.

Return Value

Type: auto

A decoded string without \s in it.


string encoded = `This\sline\sis\sencoded\:\swith\s\\s`;
string decoded = decodeIRCv3String(encoded);
assert(decoded == "This line is encoded; with \\s");
immutable s1 = decodeIRCv3String(`kameloso\sjust\ssubscribed\swith\sa\s` ~
assert((s1 == "kameloso just subscribed with a $4.99 sub. " ~
    "kameloso subscribed for 40 months in a row!"), s1);

immutable s2 = decodeIRCv3String(`stop\sspamming\scaps,\sautomated\sby\sNightbot`);
assert((s2 == "stop spamming caps, automated by Nightbot"), s2);

immutable s3 = decodeIRCv3String(`\:__\:`);
assert((s3 == ";__;"), s3);

immutable s4 = decodeIRCv3String(`\\o/ \\o\\ /o/ ~o~`);
assert((s4 == `\o/ \o\ /o/ ~o~`), s4);

immutable s5 = decodeIRCv3String(`This\sis\sa\stest\`);
assert((s5 == "This is a test"), s5);

immutable s6 = decodeIRCv3String(`9\sraiders\sfrom\sVHSGlitch\shave\sjoined\n!`);
assert((s6 == "9 raiders from VHSGlitch have joined\n!"), s6);

    immutable before = `\s\s\s`;
    immutable after = decodeIRCv3String(before);
    assert((after == "   "), after);
    assert(before !is after);
    immutable before = `foo bar`;
    immutable after = decodeIRCv3String(before);
    assert((after == "foo bar"), after);
    assert(before is after);