utf16?

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

utf16?

Johan Brichau-2
Hi,

Is there a way to produce a utf-16 encoded string (bytearray) in Gemstone?
I need to write a utf-16 encoded csv file (which is the only cross-platform way to get a csv file with correct characters imported into excel..).

Below is what I do in Pharo. Is there something that supports this in GS?

Any ideas are welcome and appreciated ;-)
Johan

self requestContext respond: [ :response |
                                        response
                                                attachmentWithFileName: 'file.csv';
                                                contentType: ((WAMimeType main: 'text' sub: 'csv')
                                                                                        charset: 'utf-16');
                                                binary.
                                        converter := UTF16TextConverter new useLittleEndian: true; useByteOrderMark: true.
                                        response nextPutAll: ((String streamContents: [:str |
                                                         self exportCSVFor: coll on: str]) convertToWithConverter: converter) asByteArray]]
Reply | Threaded
Open this post in threaded view
|

Re: utf16?

Johan Brichau-2
Ok, so I guess there is no way? ;-)

I will have to check out if the TextConverter hierarchy from Pharo can (im)ported in/to Gemstone then.

On 11 Aug 2011, at 19:11, Johan Brichau wrote:

> Hi,
>
> Is there a way to produce a utf-16 encoded string (bytearray) in Gemstone?
> I need to write a utf-16 encoded csv file (which is the only cross-platform way to get a csv file with correct characters imported into excel..).
>
> Below is what I do in Pharo. Is there something that supports this in GS?
>
> Any ideas are welcome and appreciated ;-)
> Johan
>
> self requestContext respond: [ :response |
> response
> attachmentWithFileName: 'file.csv';
> contentType: ((WAMimeType main: 'text' sub: 'csv')
> charset: 'utf-16');
> binary.
> converter := UTF16TextConverter new useLittleEndian: true; useByteOrderMark: true.
> response nextPutAll: ((String streamContents: [:str |
> self exportCSVFor: coll on: str]) convertToWithConverter: converter) asByteArray]]

Reply | Threaded
Open this post in threaded view
|

Re: utf16?

Dale Henrichs
Haha:) We have created primitives for doing the UTF8 conversion quickly... So you are correct that porting a Smalltalk-based solution is your best bet... If porting the TextConverter hierarchy is a bigger task than you want to undertake, you could look at the UTF8Encoding which does Smalltalk-based UTF8 conversion and implement a UTF16Encoding class ...

Dale

----- Original Message -----
| From: "Johan Brichau" <[hidden email]>
| To: "GemStone Seaside beta discussion" <[hidden email]>
| Sent: Friday, August 12, 2011 4:20:32 AM
| Subject: Re: [GS/SS Beta] utf16?
|
| Ok, so I guess there is no way? ;-)
|
| I will have to check out if the TextConverter hierarchy from Pharo
| can (im)ported in/to Gemstone then.
|
| On 11 Aug 2011, at 19:11, Johan Brichau wrote:
|
| > Hi,
| >
| > Is there a way to produce a utf-16 encoded string (bytearray) in
| > Gemstone?
| > I need to write a utf-16 encoded csv file (which is the only
| > cross-platform way to get a csv file with correct characters
| > imported into excel..).
| >
| > Below is what I do in Pharo. Is there something that supports this
| > in GS?
| >
| > Any ideas are welcome and appreciated ;-)
| > Johan
| >
| > self requestContext respond: [ :response |
| > response
| > attachmentWithFileName: 'file.csv';
| > contentType: ((WAMimeType main: 'text' sub: 'csv')
| > charset: 'utf-16');
| > binary.
| > converter := UTF16TextConverter new useLittleEndian: true;
| > useByteOrderMark: true.
| > response nextPutAll: ((String streamContents: [:str |
| > self exportCSVFor: coll on: str]) convertToWithConverter:
| > converter) asByteArray]]
|
|
Reply | Threaded
Open this post in threaded view
|

Re: utf16?

Carla F. Griggio
I'm reviving this thread... Johan, have you managed to export cross-platform csv files from GLASS?

Cheers!
Carla.

On Fri, Aug 12, 2011 at 1:23 PM, Dale Henrichs <[hidden email]> wrote:
Haha:) We have created primitives for doing the UTF8 conversion quickly... So you are correct that porting a Smalltalk-based solution is your best bet... If porting the TextConverter hierarchy is a bigger task than you want to undertake, you could look at the UTF8Encoding which does Smalltalk-based UTF8 conversion and implement a UTF16Encoding class ...

Dale

----- Original Message -----
| From: "Johan Brichau" <[hidden email]>
| To: "GemStone Seaside beta discussion" <[hidden email]>
| Sent: Friday, August 12, 2011 4:20:32 AM
| Subject: Re: [GS/SS Beta] utf16?
|
| Ok, so I guess there is no way? ;-)
|
| I will have to check out if the TextConverter hierarchy from Pharo
| can (im)ported in/to Gemstone then.
|
| On 11 Aug 2011, at 19:11, Johan Brichau wrote:
|
| > Hi,
| >
| > Is there a way to produce a utf-16 encoded string (bytearray) in
| > Gemstone?
| > I need to write a utf-16 encoded csv file (which is the only
| > cross-platform way to get a csv file with correct characters
| > imported into excel..).
| >
| > Below is what I do in Pharo. Is there something that supports this
| > in GS?
| >
| > Any ideas are welcome and appreciated ;-)
| > Johan
| >
| > self requestContext respond: [ :response |
| >                                     response
| >                                             attachmentWithFileName: 'file.csv';
| >                                             contentType: ((WAMimeType main: 'text' sub: 'csv')
| >                                                                                     charset: 'utf-16');
| >                                             binary.
| >                                     converter := UTF16TextConverter new useLittleEndian: true;
| >                                     useByteOrderMark: true.
| >                                     response nextPutAll: ((String streamContents: [:str |
| >                                                      self exportCSVFor: coll on: str]) convertToWithConverter:
| >                                                      converter) asByteArray]]
|
|

Reply | Threaded
Open this post in threaded view
|

Re: utf16?

Dale Henrichs
Just in case it matters, GemStone 3.1 has support for Utf8, Utf16 and Utf32 encodings...

Dale

----- Original Message -----
| From: "Carla F. Griggio" <[hidden email]>
| To: "GemStone Seaside beta discussion" <[hidden email]>
| Sent: Thursday, July 19, 2012 2:06:05 PM
| Subject: Re: [GS/SS Beta] utf16?
|
| I'm reviving this thread... Johan, have you managed to export
| cross-platform csv files from GLASS?
|
| Cheers!
| Carla.
|
|
| On Fri, Aug 12, 2011 at 1:23 PM, Dale Henrichs < [hidden email]
| > wrote:
|
|
| Haha:) We have created primitives for doing the UTF8 conversion
| quickly... So you are correct that porting a Smalltalk-based
| solution is your best bet... If porting the TextConverter hierarchy
| is a bigger task than you want to undertake, you could look at the
| UTF8Encoding which does Smalltalk-based UTF8 conversion and
| implement a UTF16Encoding class ...
|
| Dale
|
|
|
| ----- Original Message -----
| | From: "Johan Brichau" < [hidden email] >
| | To: "GemStone Seaside beta discussion" < [hidden email]
| | >
| | Sent: Friday, August 12, 2011 4:20:32 AM
| | Subject: Re: [GS/SS Beta] utf16?
| |
| | Ok, so I guess there is no way? ;-)
| |
| | I will have to check out if the TextConverter hierarchy from Pharo
| | can (im)ported in/to Gemstone then.
| |
| | On 11 Aug 2011, at 19:11, Johan Brichau wrote:
| |
| | > Hi,
| | >
| | > Is there a way to produce a utf-16 encoded string (bytearray) in
| | > Gemstone?
| | > I need to write a utf-16 encoded csv file (which is the only
| | > cross-platform way to get a csv file with correct characters
| | > imported into excel..).
| | >
| | > Below is what I do in Pharo. Is there something that supports
| | > this
| | > in GS?
| | >
| | > Any ideas are welcome and appreciated ;-)
| | > Johan
| | >
| | > self requestContext respond: [ :response |
| | > response
| | > attachmentWithFileName: 'file.csv';
| | > contentType: ((WAMimeType main: 'text' sub: 'csv')
| | > charset: 'utf-16');
| | > binary.
| | > converter := UTF16TextConverter new useLittleEndian: true;
| | > useByteOrderMark: true.
| | > response nextPutAll: ((String streamContents: [:str |
| | > self exportCSVFor: coll on: str]) convertToWithConverter:
| | > converter) asByteArray]]
| |
| |
|
|
Reply | Threaded
Open this post in threaded view
|

Re: utf16?

Johan Brichau-2
Hi Carla,

We did not pursue this any further.

Good news that GS 3.1 supports that natively. So it seems we will be directing effort towards porting our app there rather than implementing an encoder in GS 2.4

best
Johan

On 19 Jul 2012, at 23:38, Dale Henrichs wrote:

> Just in case it matters, GemStone 3.1 has support for Utf8, Utf16 and Utf32 encodings...
>
> Dale
>
> ----- Original Message -----
> | From: "Carla F. Griggio" <[hidden email]>
> | To: "GemStone Seaside beta discussion" <[hidden email]>
> | Sent: Thursday, July 19, 2012 2:06:05 PM
> | Subject: Re: [GS/SS Beta] utf16?
> |
> | I'm reviving this thread... Johan, have you managed to export
> | cross-platform csv files from GLASS?
> |
> | Cheers!
> | Carla.
> |
> |
> | On Fri, Aug 12, 2011 at 1:23 PM, Dale Henrichs < [hidden email]
> | > wrote:
> |
> |
> | Haha:) We have created primitives for doing the UTF8 conversion
> | quickly... So you are correct that porting a Smalltalk-based
> | solution is your best bet... If porting the TextConverter hierarchy
> | is a bigger task than you want to undertake, you could look at the
> | UTF8Encoding which does Smalltalk-based UTF8 conversion and
> | implement a UTF16Encoding class ...
> |
> | Dale
> |
> |
> |
> | ----- Original Message -----
> | | From: "Johan Brichau" < [hidden email] >
> | | To: "GemStone Seaside beta discussion" < [hidden email]
> | | >
> | | Sent: Friday, August 12, 2011 4:20:32 AM
> | | Subject: Re: [GS/SS Beta] utf16?
> | |
> | | Ok, so I guess there is no way? ;-)
> | |
> | | I will have to check out if the TextConverter hierarchy from Pharo
> | | can (im)ported in/to Gemstone then.
> | |
> | | On 11 Aug 2011, at 19:11, Johan Brichau wrote:
> | |
> | | > Hi,
> | | >
> | | > Is there a way to produce a utf-16 encoded string (bytearray) in
> | | > Gemstone?
> | | > I need to write a utf-16 encoded csv file (which is the only
> | | > cross-platform way to get a csv file with correct characters
> | | > imported into excel..).
> | | >
> | | > Below is what I do in Pharo. Is there something that supports
> | | > this
> | | > in GS?
> | | >
> | | > Any ideas are welcome and appreciated ;-)
> | | > Johan
> | | >
> | | > self requestContext respond: [ :response |
> | | > response
> | | > attachmentWithFileName: 'file.csv';
> | | > contentType: ((WAMimeType main: 'text' sub: 'csv')
> | | > charset: 'utf-16');
> | | > binary.
> | | > converter := UTF16TextConverter new useLittleEndian: true;
> | | > useByteOrderMark: true.
> | | > response nextPutAll: ((String streamContents: [:str |
> | | > self exportCSVFor: coll on: str]) convertToWithConverter:
> | | > converter) asByteArray]]
> | |
> | |
> |
> |