converting: QuadByteString => String

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

converting: QuadByteString => String

Nick
Hi,

I'm sure this has come up on this list before, though I didn't manage to find the answer after a brief search.

As the result for an upload from a form I have a field containing some text in a QuadByteString. I'd like to convert it into a String, that is a single byte string). 
 
In Pharo I've used something like:

myMultibyteString convertToWithConverter: Latin1TextConverter new.

What's the equivalent in Gemstone or is there a way of doing it cross-platform that I'm missing?

Thanks

Nick
Reply | Threaded
Open this post in threaded view
|

Re: converting: QuadByteString => String

NorbertHartl

On 22.11.2010, at 16:57, Nick Ager wrote:

> Hi,
>
> I'm sure this has come up on this list before, though I didn't manage to find the answer after a brief search.
>
> As the result for an upload from a form I have a field containing some text in a QuadByteString. I'd like to convert it into a String, that is a single byte string).
>  
> In Pharo I've used something like:
>
> myMultibyteString convertToWithConverter: Latin1TextConverter new.
>
> What's the equivalent in Gemstone or is there a way of doing it cross-platform that I'm missing?
>

Nick,

I do not understand your problem. If you have a seaside adaptor configured with an encoding and you get a QuadByteString than this should mean there are non-7-bit characters in the string. And the string should be just a valid string. GemStone creates either String or QuadByteString if there are non-7-bit characers. You can try to do "asString" on the string you've got. Probably that makes a DoubleByteString out of it.

However if you need to tweak the encoding I would use grease

(GRCodec forEncoding: 'latin1') decode: aMultiByteString

hope that helps,

Norbert

Reply | Threaded
Open this post in threaded view
|

Re: converting: QuadByteString => String

Dale Henrichs
In reply to this post by Nick
Nick,

If you send #asString to a QuadByteString, the string will be converted
to a String or DoubleByeString if all of the characters will fit (single
byte characters or double byte characters).

In general, GemStone automatically sizes the String  based upon the size
of the characters added to it, so presumably your QuadByteString has
some quad byte characters in it?

So if there are multi byte characters in the QuadByteString I'm not sure
how to convert them in GemStone either...I haven't looked at text
converter so I don't know exactly what they do ...

Dale

On 11/22/2010 07:57 AM, Nick Ager wrote:

> Hi,
>
> I'm sure this has come up on this list before, though I didn't manage to
> find the answer after a brief search.
>
> As the result for an upload from a form I have a field containing some
> text in a QuadByteString. I'd like to convert it into a String, that is
> a single byte string).
> In Pharo I've used something like:
>
> myMultibyteString convertToWithConverter: Latin1TextConverter new.
>
> What's the equivalent in Gemstone or is there a way of doing it
> cross-platform that I'm missing?
>
> Thanks
>
> Nick