[squeak-dev] The Trunk: Multilingual-nice.125.mcz

commits at source.squeak.org commits at source.squeak.org
Wed Jul 14 13:50:54 UTC 2010


Nicolas Cellier uploaded a new version of Multilingual to project The Trunk:
http://source.squeak.org/trunk/Multilingual-nice.125.mcz

==================== Summary ====================

Name: Multilingual-nice.125
Author: nice
Time: 14 July 2010, 3:50:21.793 pm
UUID: bd43f412-f7ac-4ab0-8124-12cec0bc0fdc
Ancestors: Multilingual-nice.124

Patch the new Unicode case conversion utilities.

=============== Diff against Multilingual-nice.124 ===============

Item was changed:
  ----- Method: Unicode class>>initializeCaseMappings (in category 'casing') -----
  initializeCaseMappings
  	"Unicode initializeCaseMappings"
+ 	ToCasefold := IdentityDictionary new.
  	ToUpper := IdentityDictionary new.
  	ToLower := IdentityDictionary new.
  	UIManager default informUserDuring: [:bar|
  		| stream |
  		bar value: 'Downloading Unicode data'.
  		stream := HTTPClient httpGet: 'http://www.unicode.org/Public/UNIDATA/CaseFolding.txt'.
  		(stream isKindOf: RWBinaryOrTextStream) ifFalse:[^self error: 'Download failed'].
  		stream reset.
  		bar value: 'Updating Case Mappings'.
  		self parseCaseMappingFrom: stream.
  	].!

Item was changed:
  EncodedCharSet subclass: #Unicode
  	instanceVariableNames: ''
+ 	classVariableNames: 'Cc Cf Cn Co Compositions Cs DecimalProperty Decompositions GeneralCategory Ll Lm Lo Lt Lu Mc Me Mn Nd Nl No Pc Pd Pe Pf Pi Po Ps Sc Sk Sm So ToCasefold ToLower ToUpper Zl Zp Zs'
- 	classVariableNames: 'Cc Cf Cn Co Compositions Cs DecimalProperty Decompositions GeneralCategory Ll Lm Lo Lt Lu Mc Me Mn Nd Nl No Pc Pd Pe Pf Pi Po Ps Sc Sk Sm So ToLower ToUpper Zl Zp Zs'
  	poolDictionaries: ''
  	category: 'Multilingual-Encodings'!
  
  !Unicode commentStamp: 'yo 10/19/2004 20:44' prior: 0!
  This class holds the entry points for the utility functions around characters.
  !

Item was added:
+ ----- Method: Unicode class>>toCasefold: (in category 'casing') -----
+ toCasefold: aWideString
+ 	"Transform a Wide String into fold case.
+ 	This is to enable case insensitive conversion."
+ 	
+ 	^aWideString collect: [:e |
+ 		(ToCasefold at: e charCode ifAbsent: [nil])
+ 			ifNil: [e]
+ 			ifNotNil: [:low | self value: low]]!

Item was changed:
  ----- Method: Unicode class>>parseCaseMappingFrom: (in category 'casing') -----
  parseCaseMappingFrom: stream
  	"Parse the Unicode casing mappings from the given stream.
  	Handle only the simple mappings"
  	"
  		Unicode initializeCaseMappings.
  	"
- 	| fields line lowerCode upperCode |
  
+ 	ToCasefold := IdentityDictionary new: 2048.
+ 	ToUpper := IdentityDictionary new: 2048.
+ 	ToLower := IdentityDictionary new: 2048.
- 	ToUpper := IdentityDictionary new: 4096.
- 	ToLower := IdentityDictionary new: 4096.
  
  	[stream atEnd] whileFalse:[
+ 		| fields line srcCode dstCode |
  		line := stream nextLine copyUpTo: $#.
  		fields := line withBlanksTrimmed findTokens: $;.
  		(fields size > 2 and: [#('C' 'S') includes: (fields at: 2) withBlanksTrimmed]) ifTrue:[
+ 			srcCode := Integer readFrom: (fields at: 1) withBlanksTrimmed base: 16.
+ 			dstCode := Integer readFrom: (fields at: 3) withBlanksTrimmed base: 16.
+ 			ToCasefold at: srcCode put: dstCode.
- 			upperCode := Integer readFrom: (fields at: 1) withBlanksTrimmed base: 16.
- 			lowerCode := Integer readFrom: (fields at: 3) withBlanksTrimmed base: 16.
- 			ToUpper at: lowerCode put: upperCode.
- 			ToLower at: upperCode put: lowerCode.
  		].
  	].
+ 
+ 	ToCasefold keysAndValuesDo:
+ 		[:k :v |
+ 		(self isUppercase: (self value: k))
+ 			ifTrue:
+ 				["In most cases, uppercase letter are folded to lower case"
+ 				ToUpper at: v put: k.
+ 				ToLower at: k put: v].
+ 		(self isLowercase: (self value: k))
+ 			ifTrue:
+ 				["In a few cases, two lower case letters are folded to the same lower case.
+ 				We must find an upper case letter folded to the same letter"
+ 				| up |
+ 				up := ToCasefold keys detect: [:e | (self isUppercase: (self value: e)) and: [(ToCasefold at: e) = v]] ifNone: [nil].
+ 				up ifNotNil: [ToUpper at: k put: up]]].!
- !




More information about the Squeak-dev mailing list