Use a lossless escaping, ie. an escaping scheme with a way to get back the original string. Right now we convert all forbidden chars to "-".
One way to do this would be URL escaping.
Note, upstream ZNC uses the "-" escaping.