WideString

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

WideString

Ramiro Diaz Trepat
Hello,
    I was parsing a small text file, character by character, onto a
collection that later on I wanted to convert to a String.
    I found that to convert a SequencableCollection of characters to a
String, I only can store the characters as Integers, then convert the
collection using #asByteArray and then call #asString.  I could not
find any other way to convert a collection filled with characters to a
String.
   The file I was parsing, contains utf8 characters, hence the
asByteArray asString sequence did not work for me.  To get it working,
I had to use #asIntegerArray and add the method #asWideString to the
class IntegerArray, with the following implementation:

IntegerArray>>asWideString
        ^ (WideString new: self size) replaceFrom: 1 to: self size with: self

Which is analogous to the ByteArray implementation of #asString.

   My questions are the following:

   Since ByteArray has the conversion method #asString, do you guys
think this method should also be added to IntegerArray to handle
WideString instances ?
   What is the proper way to submit changes to basic classes like IntegerArray ?