Jump to content

Replacing non-latin characters in string with Sanitizer::translate


j__
 Share

Recommended Posts

Hi,

probably quite simple, but I just can't get my head around this: I've got a string containing non-ASCII characters which I would like to have replaced based on InputfieldPageName module config settings (ä -> ae, á -> a, etc.). Apparenty Sanitizer::translate seems to be usable for PageName only, as in $sanitizer->pageName(string $value). But in this case PageName would limit the string length and replace all space characters with '-', which I do not want.

So in short I am looking for $sanitizer->text(string $value, Sanitizer::translate), but it does not exist. What could I do?

Link to comment
Share on other sites

13 hours ago, j__ said:

I would like to have replaced based on InputfieldPageName module config settings

These settings probably wouldn't be ideal for the purpose because they only account for lowercase replacements (page names must be lowercase).

But it seemed like a good candidate for a new sanitizer method so I made a module where you can define character replacements in the config:

 

  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...