[wp-hackers] Unicode url rewriting using add_rewrite_rule()

Deepak Mittal dpac.mittal2 at gmail.com
Wed Dec 12 19:01:44 UTC 2012


On Thu, Dec 13, 2012 at 12:11 AM, Otto <otto at ottodestruct.com> wrote:

> On Wed, Dec 12, 2012 at 12:37 PM, Otto <otto at ottodestruct.com> wrote:
> > On Wed, Dec 12, 2012 at 11:36 AM, Deepak Mittal <dpac.mittal2 at gmail.com>
> wrote:
> >> However, this still doesn't work with unicode characters as I need to
> pass
> >> a regular expression modifier 'u' with it. Any idea how I can do that?
> >
> > Sure. You can't. The regular expression used for rewrite rules doesn't
> > contain the u modifier, and there is no option to add it.
> >
> > See class-wp.php, around line 205-ish.
>
>
> BTW, unicode characters are not valid in URLs anyway. According to the
> RFC (1738), only ASCII characters are allowed in URLs. Anything else
> must be percent encoded.
>

I understand that. Browser always percent-encodes the URLs. This URL goes
to the regex engine (PCRE) as an ASCII string. This is the exact reason why
I need the 'u' modifier - to tell PCRE that the supplied string must be
treated as a Unicode string.


>
> See http://www.faqs.org/rfcs/rfc1738.html
>
> Or a better explanation here:
> http://www.blooberry.com/indexdot/html/topics/urlencoding.htm
>
> -Otto
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>



-- 
Regards,
Deepak Mittal,
Twitter - @dpacmittal


More information about the wp-hackers mailing list