Hallo
does anyone know why the String compare does the following
'n'='N' false
'n' <='N' true
'n'>='N' true
'n' >'N' false
'n' <'N' false
regards
wolfgang botzenhardt
Moderators: Eric Clayberg, wembley, tc, Diane Engles, solveig
parseRGB: spec digits: digits
"Parse a color specification string spec
of the form '#RRGGBB' with the given number of digits
for each of the red, green and blue components.
Answer a CgRGBColor or nil if there is an error."
| shift index components component digit |
shift := 16 - (digits * 4).
index := 2.
components := Array new: 3.
1 to: 3 do: [:i |
component := 0.
digits timesRepeat: [
component := component * 16.
digit := spec at: index.
($0 <= digit and: [digit <= $9])
ifTrue: [component := component + (digit value - $0 value)]
ifFalse: [
($A <= digit and: [digit <= $F])
ifTrue: [component := component + (digit value - $A value + 10)]
ifFalse: [
($a <= digit and: [digit <= $f])
ifTrue: [component := component + (digit value - $a value + 10)]
ifFalse: [^nil]]].
index := index + 1].
components at: i put: (component bitShift: shift)].
^CgRGBColor
red: (components at: 1)
green: (components at: 2)
blue: (components at: 3)
parseRGB: spec digits: digits
"Parse a color specification string spec
of the form '#RRGGBB' with the given number of digits
for each of the red, green and blue components.
Answer a CgRGBColor or nil if there is an error."
| uppercaseSpec shift index components component digit |
shift := 16 - (digits * 4).
index := 2.
components := Array new: 3.
uppercaseSpec := spec asUppercase.
1 to: 3 do: [:i |
component := 0.
digits timesRepeat: [
component := component * 16.
digit := uppercaseSpec at: index.
($0 <= digit and: [digit <= $9])
ifTrue: [component := component + (digit value - $0 value)]
ifFalse: [
($A <= digit and: [digit <= $F])
ifTrue: [component := component + (digit value - $A value + 10)]
ifFalse: [^nil]].
index := index + 1].
components at: i put: (component bitShift: shift)].
^CgRGBColor
red: (components at: 1)
green: (components at: 2)
blue: (components at: 3)
benvandijk wrote:Hi Wolfgang,
As you can see in comments of the implementor of <= in EsString, the compare is done using collating sequence (sorting order).
'n' and N' have the same place In the collating sequence.
The method sameAs: also uses the collating sequence.
Also: 'n' and 'N' are the same, but are not equal.
Greetings, Ben.
Return to VA Smalltalk 7.0, 7.5 & 8.0
Users browsing this forum: Yahoo [Bot] and 1 guest