VASmalltalk – ICU, MSKLocale, SortedCollection …

I’m about to publish version 0.0.24 and lots of stuff has been changed …

Introduction of a new Locale class

I’ve introduced a new Locale class named MSKLocale. The name is not very good and ICULocale would be perhaps better or even UnicodeLocale – but I expect, that Instantiation might use the later name, therefore I’ve chosen MSKLocale.
This new class has more or less the same features as the class Locale, but it also offers various additional informations and objecs suitable for sorting and printing.

Error Fixing

I added lots of new test cases and found errors and errors. I hope, that this version is now pretty good working even for persons using it for the first time.

Initialization and Restarting

One of the errors I’ve seen was the missing of loading/restarting support of the ICU support. Now the system in initialized (or reinitialized) when starting the image, saving the image. The system wide aware converters for UTF8, current code page and UTF16 are available after loading the code and a current instance of the new locale class is created.

Formating of DateAndTime

Formating of DateAndTime instances should now work (in so many various formarts) – output target are either instances of String or instances of Stream (but still non-unicode streams).

The following example gives an idea, what one can do with it (lots of other printable attributes are available not seen in this eample):


| anUDateFormat aString|
anUDateFormat := UDateFormat 
                    openTimeStyle: UDAT_IGNORE 
                    dateStyle: UDAT_IGNORE 
                    locale: 'de_DE' 
                    zoneName: 'Europe/Berlin' 
                    pattern: 'YYYY-MM-dd HH:mm:ss.000Z'.
aString := anUDateFormat 
                format: self defaultTestDateAndTime asUCalendar  millis 
                fieldPosition: nil.
anUDateFormat close.
self assert: (aString = '2000-12-01 13:14:15.000+0100')


A new class USortedCollection has been created to have access to locale oriented string comparision – without having external references – they have now three-value sorting blocks insead of the original two-value sorting blocks. I am not sure, if this is a good solution, but it was my first attempt to play with it.


| uSorted |
uSorted := USortedCollection 
              sortBlock: [ :a :b :l | l is: a before: b ]  
              in: MSKLocale current.
uSorted add: 'a' asUnicodeString.
uSorted add: 'b' asUnicodeString.
uSorted add: 'c' asUnicodeString.
self assert: (uSorted size = 3).
self assert: ((uSorted indexOf: 'c') = 3).
self assert: ((uSorted indexOf: 'a') = 1).
self assert: ((uSorted indexOf: 'b') = 2).

Comparing and Rules

Sorting and comparing under Unicode – what a difficult topic and I’ve perhaps have only reached some stuff on the surface. I’ve added Collator objects (comparing objects) offering DIN5007-01 and DIN5007-02 sorting services. Collator objects can be individual defined for sorting via so called “rules”.

Therefore you are allowed to compare stuff like the following:


| uCollator result  |

uCollator := UCollator collatorForDIN500702.
result := uCollator is: 'bücher' equalTo: 'buecher'.	
uCollator close.
self assert: result


Perhaps some words about installation. The whole code works under Windows only – up to now. In general the whole stuff should work under AIX, Linux, Windos and Solaris. ICU is supported on all these platforms (perhaps not always in 32bit (AIX, Solaris), then one has to manually compile the library).

The C-libraries can be downloaded from ICU4C and I added “icudt48.dll”, “icuin48.dll”, “icuio48.dll”, “icule48.dll”, “iculx48.dll”, “icutu48.dll” and “icuuc48.dll” to the “bin”-directory of your running VA application/IDE. The file “icudt48.dll” is the largest one (17 MB). It contains all timezone data informations, locale informations and all that stuff.

Please be aware of the fact, that the whole code is a moving target …. 🙂

This entry was posted in Smalltalk and tagged , , , . Bookmark the permalink.

One Response to VASmalltalk – ICU, MSKLocale, SortedCollection …

  1. Great work Marten! Really nice to have the rich I18N functionality of ICU4J available in Smalltalk.

    Note that I have started a port of your work to Pharo Smalltalk. I just ported a single piece of functionality but I got it working on Win32, MacOSX and Ubuntu Linux. See In Pharo has something called FFI for integrating external libraries.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s