Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
parseGeneralPropertiesFrom: aStream (UCD, Cuis Smalltalk)
Last updated at 7:50 pm UTC on 12 December 2015
(Back to Cuis-Smalltalk-Unicode)

Code that parses the general character properties of the UCD

https://github.com/KenDickey/Cuis-Smalltalk-Unicode/blob/master/UniCodes.pck.st#L6461

| toNumber |
toNumber := [:quad | ('16r', quad) asNumber].
GeneralCategory := IdentityDictionary new: 24430..
[aStream atEnd] whileFalse:[
    | fields line codePoint generalCategory |
    line := aStream nextLine.
    fields := line withBlanksTrimmed findTokens: $;.
    (fields size > 3) ifTrue: [.
        codePoint := toNumber value: (fields at: 1).
        (codePoint asUniChar isCJKIdeograph) ifFalse: [ "add it"
            generalCategory := self perform: ((fields at: 3) asSymbol).
            GeneralCategory at: codePoint put: generalCategory
        ]
    ]
].
! !