VASmalltalk – ICU – Character class

after reading the specification I think that the Character class can be used for Unicode (at least in the first step) and therefore with version 0.0.31 I add a new library (mskunicode.dll) to the ICU wrapper and the only content (so far) is a primitive to set the value of a character from 0 .. 0x1FFFFF (instead of 0 .. 0xFFFF):

// Now some primitive functions as extensions for Character class - these primitive
// should make it possible to store 21 bits integer values into instances of Characters
#define	MSKUTF32ToCharacter(c)	((EsObject) (((((U_32) (c)) & 0x1FFFFF) << EsShiftCharacter) | EsTagCharacter))

EsUserPrimitive(MSKCharSetVal)
{
	I_32 i1;
	U_32 rc;

	rc = EsIntegerToI32(EsPrimArgument(1), &i1);
	if (rc != EsPrimErrNoError)
		EsPrimFail(rc, 1);
	EsPrimSucceed(MSKUTF32ToCharacter(i1));
}

The getter-methods return these larger values.

Because immediate objects may store up to 28 bits the 21 bits of an unicode character should be possible.

There are other methods in Character, that are not suitable for values larger than 0xFFFF – but perhaps this can be changed later. Surprising, one can not add subclasses to Character.

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

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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