WP encode post title into Percent-Encoding URL

Bằng Nguyễn asked
wordpress urlencode
via

I’m trying to covert post title into percent-encodeing. For example:

nhà giả kim -> nh%C3%A0%20gi%E1%BA%A3%20kim

I found this website do exactly what I want but there is no guide to intergrate into Wordpress. Any help?


Answer
via

There is a built-in PHP function rawurlencode() that can do this.

<?php
echo rawurlencode('nhà giả kim');
// nh%C3%A0%20gi%E1%BA%A3%20kim

See also: rawurldecode()

Share This
Posted in: