Skip to content

Instantly share code, notes, and snippets.

@PVince81
Created March 15, 2022 09:38
Show Gist options
  • Save PVince81/2ada57dd1e7920b0460c43c5bc778d98 to your computer and use it in GitHub Desktop.
Save PVince81/2ada57dd1e7920b0460c43c5bc778d98 to your computer and use it in GitHub Desktop.
<?php
$s = $argv[1];
if (\Normalizer::isNormalized($s, \Normalizer::FORM_D)) {
print("Original string is using NFD normalization\n");
$nfc = \Normalizer::normalize($s, \Normalizer::FORM_C);
print("NFC: $nfc\n");
print("NFD: $s\n");
} elseif (\Normalizer::isNormalized($s, \Normalizer::FORM_C)) {
print("Original string is using NFC normalization\n");
$nfd = \Normalizer::normalize($s, \Normalizer::FORM_D);
print("NFC: $s\n");
print("NFD: $nfd\n");
} else {
print("Unknown normalization\n");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment