Made escape() and unescape() more robust towards undef input and NULL output