Fix permalink storage for v4 schema

Links are stored as "l,<link id>" or "l,<link id>,<comment id>" if there are comments
Modmail links are stored as "m,<message id>".

Also includes better handling of internationalized titles in links.