can pharo change encoding of a file?
Hi, is there a way to reencode a file from within Pharo? e.g. I have a file in CP1250 encoding and I want to change it to UTF-8. In linux I would do something like "recode cp1250..utf8 file.txt". But can Pharo do that natively, or do I need to defer to the system with FFI/OSSubprocess? Thanks, Peter
You can, check the ZnCharacterReadStream and ZnCharacterWriteStream classes. You can configure them with an encoding and voilá. Guille On Tue, Jul 5, 2016 at 12:14 PM, Peter Uhnák <i.uhnak@gmail.com> wrote:
Hi,
is there a way to reencode a file from within Pharo?
e.g. I have a file in CP1250 encoding and I want to change it to UTF-8.
In linux I would do something like "recode cp1250..utf8 file.txt".
But can Pharo do that natively, or do I need to defer to the system with FFI/OSSubprocess?
Thanks, Peter
Yes, ZnCharacterEncoder newForEncoding: #cp1250 gives you all you need. You can use the stream classes Guile mentioned. Just make sure you do your underlying, basic file IO binary.
On 05 Jul 2016, at 12:21, Guillermo Polito <guillermopolito@gmail.com> wrote:
You can, check the ZnCharacterReadStream and ZnCharacterWriteStream classes. You can configure them with an encoding and voilá.
Guille
On Tue, Jul 5, 2016 at 12:14 PM, Peter Uhnák <i.uhnak@gmail.com> wrote: Hi,
is there a way to reencode a file from within Pharo?
e.g. I have a file in CP1250 encoding and I want to change it to UTF-8.
In linux I would do something like "recode cp1250..utf8 file.txt".
But can Pharo do that natively, or do I need to defer to the system with FFI/OSSubprocess?
Thanks, Peter
Perfect! Thank you both. Peter On Tue, Jul 5, 2016 at 12:49 PM, Sven Van Caekenberghe <sven@stfx.eu> wrote:
Yes,
ZnCharacterEncoder newForEncoding: #cp1250
gives you all you need.
You can use the stream classes Guile mentioned. Just make sure you do your underlying, basic file IO binary.
On 05 Jul 2016, at 12:21, Guillermo Polito <guillermopolito@gmail.com> wrote:
You can, check the ZnCharacterReadStream and ZnCharacterWriteStream classes. You can configure them with an encoding and voilá.
Guille
On Tue, Jul 5, 2016 at 12:14 PM, Peter Uhnák <i.uhnak@gmail.com> wrote: Hi,
is there a way to reencode a file from within Pharo?
e.g. I have a file in CP1250 encoding and I want to change it to UTF-8.
In linux I would do something like "recode cp1250..utf8 file.txt".
But can Pharo do that natively, or do I need to defer to the system with FFI/OSSubprocess?
Thanks, Peter
participants (3)
-
Guillermo Polito -
Peter Uhnák -
Sven Van Caekenberghe