WP encode post title into Percent-Encoding URL

Bằng Nguyễn asked
wordpress urlencode

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?


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

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

See also: rawurldecode()

Share This
Posted in: