Migration Guide : Migrating from Version 14.0.0 : Allowed arguments to UnicodeWriteStream >>#nextPutAll: have changed
Allowed arguments to UnicodeWriteStream >>#nextPutAll: have changed
UnicodeWriteStream>>#nextPutAll: has been lenient about the arguments passed for addition to the stream, sending them #asUnicodeString.
If UnicodeWriteStream were used explicitly, code that relied on this argument conversion may exist.
Example 1
UnicodeString new writeStream
nextPutAll: #[101 204 129];
nextPutAll: 42;
nextPutAll: (Grapheme value: '\u{20AC}');
contents.
Formerly the above expression would have the contents 'é*€'. Now, the above code will cause errors.
But previously erroring collection of elements will now work:
Example 2
UnicodeString new writeStream
nextPutAll: #($a $b $c);
contents.
Now the above expression has the contents 'abc'.
The following example highlights the use of different collection classes and syntax which mix Unicode strings and core Strings. This is another example of previously erroring collection of elements will now work.
Example 3
(UnicodeString new writeStream)
nextPutAll: (Array with: ( Grapheme escaped: '\x53')
with: (Grapheme escaped: '\u{1F600}'));
nextPutAll: (OrderedCollection with: $t asGrapheme
with:$o asGrapheme);
cr;
nextPutAll: #( $t $o );
contents.
Formerly, the above expression would fail with a walkback. Now, the expression has the contents
'S😀to
to'
In summary, if you relied on "strange" classes implementing #asUnicodeString, and added instances of those using nextPutAll: , this will now fail with a walk back.
“Strange” is defined as any implementor of #asUnicodeString - either non-collection class (e.g., Integer), or collection class containing incompatible elements (e.g., ByteArray). Such classes will now fail.
Reason for change
UnicodeWriteStream>>#nextPutAll: was made more conformant with the standard WriteStream definition.
It now accepts as an argument a collection of compatible elements, whereas it used to accept any implementor of #asUnicodeString.
Action required
If code relied on asUnicodeString being used to automatically convert nextPutAll: arguments that are not collections of compatible elements, explicit asUnicodeString calls must be added to preserve the old behavior:
Example 1, with the required modification
UnicodeString new writeStream
nextPutAll: #[101 204 129] asUnicodeString;
nextPutAll: 42 asUnicodeString;
nextPutAll: (Grapheme value: '\u{20AC}') asUnicodeString;
contents.
With this modification the former contents is restored to 'é*€' .
Last modified date: 07/15/2025