Last active
February 28, 2018 09:08
-
-
Save iegik/1302029 to your computer and use it in GitHub Desktop.
Replace āēūīšģķļ to aeuisgkl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// shim for String.prototype.normalize https://github.com/walling/unorm | |
export default str => str.normalize('NFKD') | |
.replace(/[\u0300-\u036f]/g, "") // remove accents | |
.replace(/\u0142/g, "l"); // ł is a letter in itself | |
/* | |
const normalize = import('normalize.js') | |
console.log(normalize('ąśćńżółźćęāēūīšģķļ')) | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
return function normalize($str) { | |
$normalized = Normalizer::normalize($str, Normalizer::NFKD); | |
$normalized = preg_replace('/[\u0300-\u036f]/g', '', $normalized); | |
$normalized = preg_replace('/\u0142/g', 'l', $normalized); | |
return $normalized; | |
} | |
/* | |
normalize = include 'normalize.php' | |
echo normalize('ąśćńżółźćęāēūīšģķļ'); | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment