Nick,
The trouble with using a ByteArray is that we don't know the encoding...
You can use ByteArray>>asString to convert a ByteArray to a string, but the assumption is that you've got single byte characters.
If you look at ByteArray>>asString the code starts with a String and loops over the ByteArray and then converts each byte into a Character and then adds the character to the collection.
This is probably the direction that you want to go, because GemStone will automatically mutate a String to a DoubleByteString if you add a double byte character to the collection. If you know your encoding, you can loop over the bytearray, creating the appropriate Character instance and you are off to the races.
Another alternative, is to create your strings from UTF8 encoded Strings ... then you can take the String and use the #decodeFromUTF8 to create your DoubleByteString ... the decoding is done in a primitive and is pretty efficient ...
Does this help?
Dale
----- Original Message -----
| From: "Nick Ager" <
[hidden email]>
| To: "GemStone Seaside beta discussion" <
[hidden email]>
| Sent: Friday, February 24, 2012 9:49:50 AM
| Subject: [GS/SS Beta] cross platform multibyte strings
|
|
| Hi,
|
| I'm struggling with multibyte strings in Gemstone. Is there a way to
| construct one from a ByteArray?
|
|
| I'm trying something like:
|
|
|
|
| QuadByteString withAll: ( #(0 0 1 146 0 0 0 97 0 0 1 144 0 0 0 98)
| asByteArray)
|
|
| Which generates an error. I've probably missed something simple - but
| can't see it at the moment.
|
|
| Thanks
|
|
| Nick
|
|
|
|
|