Nicolas Cellier uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-nice.196.mcz ==================== Summary ==================== Name: Multilingual-nice.196 Author: nice Time: 29 May 2014, 2:59:48.329 pm UUID: 07f39804-8e14-49be-a55f-e8d2b809fddd Ancestors: Multilingual-nice.195 Generalized what I did to Unicode: provide an API dealing with codes Add charsetClass conveniency for this reason: (EncodedCharSet charsetAt: leadingChar) is not always a charset, it can also be a LanguageEnvironment. (EncodedCharSet charsetAt: leadingChar) charsetClass will always be a charset (an EncodedCharSet subclass) =============== Diff against Multilingual-nice.195 =============== Item was added: + ----- Method: EncodedCharSet class>>charsetClass (in category 'class methods') ----- + charsetClass + ^self! Item was added: + ----- Method: EncodedCharSet class>>convertToUnicode: (in category 'class methods') ----- + convertToUnicode: aCode + "Translate aCode in our encoding, into equivalent unicode encoding" + | table v | + (table := self ucsTable) ifNil: [^ 16rFFFD]. + (v := table at: 1 + self charCode) = -1 ifTrue: [^ 16rFFFD]. + ^ v! Item was changed: ----- Method: EncodedCharSet class>>isDigit: (in category 'character classification') ----- isDigit: char + "Answer whether char has the code of a digit in this encoding." + ^self isDigitCode: char charCode - "Answer whether the receiver is a digit." - - | value | - value := char asciiValue. - ^ value >= 48 and: [value <= 57]. ! Item was added: + ----- Method: EncodedCharSet class>>isDigitCode: (in category 'character classification') ----- + isDigitCode: anInteger + "Answer whether anInteger is the code of a digit." + + ^ anInteger >= 48 and: [anInteger <= 57]. + ! Item was changed: ----- Method: EncodedCharSet class>>isLetter: (in category 'character classification') ----- + isLetter: char + "Answer whether char has the code of a letter in this encoding." + ^self isLetterCode: char charCode! - isLetter: char - "Answer whether the receiver is a letter." - - | value | - value := char asciiValue. - ^ (8r141 <= value and: [value <= 8r172]) or: [8r101 <= value and: [value <= 8r132]]. - ! Item was added: + ----- Method: EncodedCharSet class>>isLetterCode: (in category 'character classification') ----- + isLetterCode: anInteger + "Answer whether anInteger is the code of a letter." + + ^ (8r141 <= anInteger and: [anInteger <= 8r172]) or: [8r101 <= anInteger and: [anInteger <= 8r132]]. + ! Item was changed: ----- Method: EncodedCharSet class>>isLowercase: (in category 'character classification') ----- + isLowercase: char + "Answer whether char has the code of a lowercase letter in this encoding." + ^self isLowercaseCode: char charCode! - isLowercase: char - "Answer whether the receiver is a lowercase letter. - (The old implementation answered whether the receiver is not an uppercase letter.)" - - | value | - value := char asciiValue. - ^ 8r141 <= value and: [value <= 8r172]. - ! Item was added: + ----- Method: EncodedCharSet class>>isLowercaseCode: (in category 'character classification') ----- + isLowercaseCode: anInteger + "Answer whether anInteger is the code of a lowercase letter." + + ^ 8r141 <= anInteger and: [anInteger <= 8r172]. + ! Item was changed: ----- Method: EncodedCharSet class>>isUppercase: (in category 'character classification') ----- + isUppercase: char + "Answer whether char has the code of an uppercase letter in this encoding." + ^self isUppercaseCode: char charCode! - isUppercase: char - "Answer whether the receiver is an uppercase letter. - (The old implementation answered whether the receiver is not a lowercase letter.)" - - | value | - value := char asciiValue. - ^ 8r101 <= value and: [value <= 8r132]. - ! Item was added: + ----- Method: EncodedCharSet class>>isUppercaseCode: (in category 'character classification') ----- + isUppercaseCode: anInteger + "Answer whether anInteger is the code of an uppercase letter." + + ^ 8r101 <= anInteger and: [anInteger <= 8r132]. + ! Item was removed: - ----- Method: GB2312 class>>isLetter: (in category 'character classification') ----- - isLetter: char - - | value leading | - - leading := char leadingChar. - value := char charCode. - - leading = 0 ifTrue: [^ super isLetter: char]. - - value := value // 94 + 1. - ^ 1 <= value and: [value < 84]. - ! Item was added: + ----- Method: GB2312 class>>isLetterCode: (in category 'character classification') ----- + isLetterCode: anInteger + | value | + value := anInteger // 94 + 1. + ^ 1 <= value and: [value < 84]. + ! Item was removed: - ----- Method: JISX0208 class>>isLetter: (in category 'character classification') ----- - isLetter: char - - | value leading | - - leading := char leadingChar. - value := char charCode. - - leading = 0 ifTrue: [^ super isLetter: char]. - - value := value // 94 + 1. - ^ 1 <= value and: [value < 84]. - ! Item was added: + ----- Method: JISX0208 class>>isLetterCode: (in category 'character classification') ----- + isLetterCode: anInteger + | value | + value := anInteger // 94 + 1. + ^ 1 <= value and: [value < 84]. + ! Item was removed: - ----- Method: KSX1001 class>>isLetter: (in category 'character classification') ----- - isLetter: char - - | value leading | - - leading := char leadingChar. - value := char charCode. - - leading = 0 ifTrue: [^ super isLetter: char]. - - value := value // 94 + 1. - ^ 1 <= value and: [value < 84]. - ! Item was added: + ----- Method: KSX1001 class>>isLetterCode: (in category 'character classification') ----- + isLetterCode: anInteger + | value | + value := anInteger // 94 + 1. + ^ 1 <= value and: [value < 84]. + ! Item was added: + ----- Method: LanguageEnvironment class>>charsetClass (in category 'accessing') ----- + charsetClass + ^Unicode! Item was changed: ----- Method: LanguageEnvironment class>>digitValueOf: (in category 'accessing') ----- digitValueOf: char "Answer 0-9 if the receiver is $0-$9, 10-35 if it is $A-$Z, and < 0 otherwise. This is used to parse literal numbers of radix 2-36." + ^ self charsetClass digitValueOf: char. - ^ Unicode digitValueOf: char. ! Item was changed: ----- Method: LanguageEnvironment class>>isDigit: (in category 'accessing') ----- isDigit: char + ^ self charsetClass isDigit: char. - ^ Unicode isDigit: char. ! Item was changed: ----- Method: LanguageEnvironment class>>isLetter: (in category 'accessing') ----- isLetter: char + ^ self charsetClass isLetter: char. - ^ Unicode isLetter: char. ! Item was changed: ----- Method: LanguageEnvironment class>>isLowercase: (in category 'accessing') ----- isLowercase: char + ^ self charsetClass isLowercase: char. - ^ Unicode isLowercase: char. ! Item was changed: ----- Method: LanguageEnvironment class>>isUppercase: (in category 'accessing') ----- isUppercase: char + ^ self charsetClass isUppercase: char. - ^ Unicode isUppercase: char. ! Item was added: + ----- Method: Latin1 class>>convertToUnicode: (in category 'class methods') ----- + convertToUnicode: aCode + ^aCode! Item was removed: - ----- Method: Latin1 class>>isLetter: (in category 'character classification') ----- - isLetter: char - "Answer whether the receiver is a letter." - - ^ Unicode isLetter: char. - - ! Item was added: + ----- Method: Latin1 class>>isLetterCode: (in category 'character classification') ----- + isLetterCode: anInteger + ^ Unicode isLetterCode: anInteger + + ! Item was added: + ----- Method: Unicode class>>convertToUnicode: (in category 'class methods') ----- + convertToUnicode: aCode + ^aCode! Item was removed: - ----- Method: Unicode class>>isDigit: (in category 'character classification') ----- - isDigit: char - ^self isDigitCode: char charCode! Item was removed: - ----- Method: Unicode class>>isLetter: (in category 'character classification') ----- - isLetter: char - ^self isLetterCode: char charCode! Item was removed: - ----- Method: Unicode class>>isLowercase: (in category 'character classification') ----- - isLowercase: char - ^self isLowercaseCode: char charCode! Item was removed: - ----- Method: Unicode class>>isUppercase: (in category 'character classification') ----- - isUppercase: char - ^self isUppercaseCode: char charCode! |
Free forum by Nabble | Edit this page |