'From Squeak3.9alpha of 4 July 2005 [latest update: #7035] on 30 June 2006 at 2:51:36 am'! "Change Set: Unicode-kwl Date: 30 June 2006 Author: Klaus D. Witzel < use the old and the new categories for isDigit, isLetter, isLowercase and isUppercase then rewrite the GeneralCategory SparseLargeTable >"! EncodedCharSet subclass: #Unicode instanceVariableNames: '' classVariableNames: 'Cc Cf Cn Co Cs DecimalProperty GeneralCategory Ll Lm Lo Lt Lu Mc Me Mn Nd Nl No Pc Pd Pe Pf Pi Po Ps Sc Sk Sm So Zl Zp Zs' poolDictionaries: '' category: 'Multilingual-Encodings'! !SparseLargeTable methodsFor: 'accessing' stamp: 'kwl 6/30/2006 03:02'! zapDefaultOnlyEntries | lastIndex newInst | 1 to: self basicSize do: [:i | (self allDefaultValueSubtableAt: i) ifTrue: [self basicAt: i put: nil]. ]. lastIndex _ self findLastNonNilSubTable. lastIndex = 0 ifTrue: [^ self]. newInst _ self class new: lastIndex*chunkSize chunkSize: chunkSize arrayClass: (self basicAt: lastIndex) class base: base defaultValue: defaultValue. newInst privateSize: self size. base to: newInst size do: [:i | newInst at: i put: (self at: i)]. 1 to: newInst basicSize do: [:i | (newInst allDefaultValueSubtableAt: i) ifTrue: [newInst basicAt: i put: nil]. ]. " this is not allowed in production: self becomeForward: newInst. " ^ newInst. ! ! !Unicode class methodsFor: 'character classification' stamp: 'kwl 6/30/2006 01:39'! isDigit: char | value codeCat | value := char charCode. value > (GeneralCategory size - 1) ifTrue: [^ false]. ^ ((codeCat := GeneralCategory at: value + 1) isInteger and: [codeCat = Nd]) or: [codeCat = 'Nd']! ! !Unicode class methodsFor: 'character classification' stamp: 'kwl 6/30/2006 01:40'! isLetter: char | value codeCat | value := char charCode. value > (GeneralCategory size - 1) ifTrue: [^ false]. ^ ((codeCat := GeneralCategory at: value + 1) isInteger and: [codeCat >= Ll and: [codeCat <= Lu]]) or: [codeCat isString and: [codeCat first = $L]]! ! !Unicode class methodsFor: 'character classification' stamp: 'kwl 6/30/2006 01:41'! isLowercase: char | value codeCat | value := char charCode. value > (GeneralCategory size - 1) ifTrue: [^ false]. ^ ((codeCat := GeneralCategory at: value + 1) isInteger and: [codeCat = Ll]) or: [codeCat = 'Ll']! ! !Unicode class methodsFor: 'character classification' stamp: 'kwl 6/30/2006 01:42'! isUppercase: char | value codeCat | value := char charCode. value > (GeneralCategory size - 1) ifTrue: [^ false]. ^ ((codeCat := GeneralCategory at: value + 1) isInteger and: [codeCat = Lu]) or: [codeCat = 'Lu']! ! !Unicode class methodsFor: 'class initialization' stamp: 'kwl 6/30/2006 01:57'! initialize " Unicode initialize " | newGeneralCategory every256 | (self classPool keys select: [:sym | sym size = 2 and: sym first isUppercase and: sym last isLowercase]) asSortedCollection inject: 1 into: [:index :sym | sym = #Cn ifTrue: [self classPool at: sym put: 0. index] ifFalse: [self classPool at: sym put: index. index + 1]]. newGeneralCategory := SparseLargeTable new: GeneralCategory size chunkSize: GeneralCategory chunkSize arrayClass: ByteArray base: 1 defaultValue: Cn. every256 := nil. 'rewriting the GeneralCategory SparseLargeTable' displayProgressAt: Sensor cursorPoint from: 0 to: ((GeneralCategory size bitOr: 255) bitShift: -8) during: [:bar | GeneralCategory withIndexDo: [:codeCat :codeIndex | every256 = (codeIndex bitShift: -8) ifFalse: [bar value: (every256 := codeIndex bitShift: -8)]. newGeneralCategory at: codeIndex put: (self classPool at: codeCat asSymbol)]]. GeneralCategory := newGeneralCategory zapDefaultOnlyEntries! ! Unicode initialize!