Andrew P. Black wrote > The Pharo image has a table of Unicode Character Categories in a class > variable GeneralCategory of class Unicode. But there do not seem to be > many methods to interpret this data. For example, while there is a method > > Unicode class >> #isDigit: aCharacter > > that checks if the Unicode category of aCharacter is Nd, and > > Unicode class >> #isLetter: aCharacter > > that checks if aCharacter is in one of the letter categories, there does > not seem to be a general way of asking “what is the category of this > character”. > > I want to check if a character is a mathematical symbol, that is, if it is > in the Unicode Category Sm. What’s the right way of doing this? > Would it be reasonable to add a method Unicode class >> #category: > aCharacter that answers one of the 29 category symbols #Cc to #Zs? Or > “is” methods for each category? > > Andrew
Hi Andrew, I would recommend the guideline that "special codes" should be modelled as private to the class (or family of classes) in question and answers to questions like "is it a mathematical symbol" be answered by a method with almost that exact name. There may be a justification for exposing the code itself, but not for directly interpreting the meaning of the code. A contrived example would be to answer a Dictionary grouping each UnicodeCharacterData instance by its General Category so that one could manipulate the set of related instances in some manner. As I said, contrived. Also, the existing methods provide a template (pattern?) for future such methods. -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html
