URI safe encoding/decoding

Change-Id: If63dd8ac962863cc0d9815180f315b391e2c8b4e