0

It got my by surprise yesterday than ordinal indicators are considered letters. I thought letters were only [a-zA-Z].

Why are they considered letters and not symbols?

    char.IsLetter('º'); // true
    char.IsLetter('ª'); // true
    char.IsLetter('°'); // false
    char.IsLetter('ᵗ'); // true 

Is there any flag I can look for to detect that for example is a superscript?

Out of curiosity, is there any other letter that is not in the [a-zA-Z] range?

6
  • 5
    My first name would like to have a word with you about your definition of "letter". Apr 4, 2017 at 9:07
  • 2
    Because the 7-bit era is over and has been for half a lifetime. Apr 4, 2017 at 9:11
  • Someone had to make decision about the implementation of .IsLetter so simply lookup the implementation or the documentation to make sure the method behaves as you expect it.
    – MrSmith42
    Apr 4, 2017 at 9:28
  • 2
    Apparently it's part of the "Letter, Modifier [Lm]" unicode category. CharUnicodeInfo.GetUnicodeCategory('ᵗ') == UnicodeCategory.ModifierLetter Apr 4, 2017 at 9:50
  • 1
    Basic Unicode knowledge should be mandatory for any developer. Including me. Everyday I learn something new about Unicode. Even after reading this article from Joel On Software years ago.
    – Machado
    Apr 4, 2017 at 15:01

1 Answer 1

7

.NET follows the unicode standard, just google for the character and unicode to find some helpful information.

  • 'º' is MASCULINE ORDINAL INDICATOR

    Part of the Letter, Other [Lo] category.

  • 'ª' is FEMININE ORDINAL INDICATOR

    Part of the Letter, Other [Lo] category.

  • '°' is DEGREE SIGN

    Part of the Symbol, Other [So] category.

  • 'ᵗ' is MODIFIER LETTER SMALL T

    Part of the Letter, Modifier [Lm] category

You can check the unicode category using CharUnicodeInfo.GetUnicodeCategory which returns a UnicodeCategory.

For example:

CharUnicodeInfo.GetUnicodeCategory('ᵗ') == UnicodeCategory.ModifierLetter
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.