skip to Main Content

In one of our applications that is connected to facebook leads, we are getting some strange first names and last names. After some googling, I found that for some reason some people are writing their name using Mathematical Script, for example: “`𝓛𝓪𝓾𝓻𝓮𝓽𝓽𝓮““

For example the big L: https://www.compart.com/en/unicode/U+2112

Is there any way I can convert this to normal script? Without doing an comparison table?

This is a completely valid char, and we are showing them correctly due to using all mb_* string functions, so it doesn’t affect the functionality. It’s more a question of appearance than anything else.

2

Answers


  1. Try Normalizer

    Normalizer::normalize('𝓛𝓪𝓾𝓻𝓮𝓽𝓽𝓮', Normalizer::FORM_KD);
    
    Login or Signup to reply.
  2. You can use the Normalizer class in PHP to achieve this. Here’s a simple example of how you can normalize the text:

    <?php
    $originalName = '𝓛𝓪𝓾𝓻𝓮𝓽𝓽𝓮';
    $normalized = Normalizer::normalize($originalName, Normalizer::FORM_C);
    
    echo $normalized; // Output: Laurette
    
    ?>
    

    This will normalize the string $originalName into its canonical decomposition, which should convert the mathematical script characters into their regular script equivalents.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search