Unicode Characters by Patrik

Replace MATHEMATICAL with LATIN LETTER

Some webpages use Unicode characters to display some text as bold. Copying will keep this format, even if you try to just paste it as plain text.

So the following script will convert from "MATHEMATICAL BOLD CAPITAL" to "LATIN CAPITAL LETTER".

So, for example, the bold letter "A" would be "f0 9d 90 80" as UTF-8. Looking at the Unicode/UTF-8-character table - snippet, we can translate this to Unicode "U+1D400". We then use the ConvertFromUtf32 method to get this as the old value in the Replace method and just the letter "A" as the new value. 

public static string ConvertBold(string input)
{
    var output = input.Replace(char.ConvertFromUtf32(0x1D5D4), "A");
    output = input.Replace(char.ConvertFromUtf32(0x1D5D5), "B");
    // ...

    output = output.Replace(char.ConvertFromUtf32(0x1D5EE), "a");
    output = output.Replace(char.ConvertFromUtf32(0x1D5EF), "b");
    // ...

    return output;
}

Comments

Leave a Comment

All fields are required. Your email address will not be published.