How to convert unicode string to ascii

How to convert unicode string to ascii to create nice string for friendly url?

+2
source share
1 answer

There is only a short list of characters that can be safely wrapped in the component of the URL path.

unreserved  = ALPHA / DIGIT / "-" / "." / "_" / "~"

All other characters must be removed (if you create a "slug") or escaped.

Deletion can be done using regular expression /[^a-zA-Z0-9-._~]/.

Sketching can be done with encodeURIComponent().

ICONV (.. Γ© e € EUR), , , ,

+9

Source: https://habr.com/ru/post/1788623/


All Articles