Add IsCSharpIdentifier() and IsCSharpIdentifierPart() methods to Character class #1
Labels
good first issue
Good for newcomers
is:feature
pri:low
up for grabs
This issue is open to be worked on by anyone
Similar methods were part of the JDK implementation. The rules for how to implement these methods for C# are documented here.
The spot reserved for them to match the Apache Harmony's implementation's order is here.
See this usage example for a real-world perspective of how these methods work together to detect a valid class name.
Note there is also a port of the Java identifier code to C# in Spatial4n which might come in useful for working out some of the more complex rules, but we should prefer the implementation style of Apache Harmony and avoid the
Regex
class, if possible. TheRegex
class documentation might come in handy for some clues about how to handle certain character classes, see Character classes in regular expressions.Also, the Spatial4n implementation has some shortcomings:
c < 0x00d800 && c > 0x00dfff
In the latter case, the code point would have to be converted to a surrogate pair before passed into
CharUnicodeInfo.GetUnicodeCategory()
as was done in other methods of theCharacter
class, such as GetType(). However, since the Apache Harmony implementation uses theGetType()
method directly, using that example will avoid this issue.The text was updated successfully, but these errors were encountered: