russellallen / self

Making the world safe for objects
http://selflanguage.org
707 stars 76 forks source link

'string capitalizeAll' doesn't work for numbers #124

Closed doublec closed 7 years ago

doublec commented 7 years ago

If I try to capitalize a string with numbers, the numbers are changed to unprintable characters:

'abcd1234defg' capitalizeAll
'ABCD????DEFG'

Tested with github master branch.

russellallen commented 7 years ago

Lol. Well the simplest fix is to change:

capitalizeAll = (copyMutable mapBy: [|:c| c isCapitalized ifTrue: c False: [(c asByte + capitalizationDifference) asCharacter]])

to

copyMutable mapBy: [|:c| (c isLetter not || c isCapitalized) ifTrue: c False: [(c asByte + capitalizationDifference) asCharacter]]

unless you have a better idea...

davidungar commented 7 years ago

Yes, that's an amusing bug!

On Sep 5, 2017, at 4:35 PM, Russell Allen notifications@github.com wrote:

Lol. Well the simplest fix is to change:

capitalizeAll = (copyMutable mapBy: [|:c| c isCapitalized ifTrue: c False: [(c asByte + capitalizationDifference) asCharacter]])

to

copyMutable mapBy: [|:c| (c isLetter not || c isCapitalized) ifTrue: c False: [(c asByte + capitalizationDifference) asCharacter]]

unless you have a better idea...

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

doublec commented 7 years ago

Looks good to me!

russellallen commented 7 years ago

Fixed - Commit 93b24da on dev branch