define corresponding safely_encode