ValeriiVasin
ValeriiVasin

Reputation: 8716

Locale independent string search in Javascript

Is there a way for searching / comparing strings without consideration of locale?

I mean: if I have two input sources on my keyboard (Russian and English) and I start typing - I want to search word without consideration what input source is active at the moment.

And I'll find string contained "Search" without metter what I've typed "search" or "ыуфкср"

Thanks.

Upvotes: 2

Views: 339

Answers (2)

Dmitry Pashkevich
Dmitry Pashkevich

Reputation: 13536

You would simply need to do search by two phrases: the original input and the result of conversion to another keyboard layout. You would have a conversion map like this:

{
    a: 'ф',
    s: 'ы',
    d: 'в',
    f: 'а',
    ...
}

Upvotes: 1

Danil Speransky
Danil Speransky

Reputation: 30473

When I think about it, I come to the conclusion that there is no correct way to implement this, even if we want such opportunity. One reason: there may be different keyboards (when on one keyboard 'a' is equal to 'ф' and on other one it is equal to 'ы'). So probably you should implement such functionllity by your self.

Upvotes: 1

Related Questions