encode path segments to support reserved chars