Is there any way to read a codepage 437 encoded file with pharo?
thanks, Norbert |
Norbert,
> On 20 Oct 2015, at 14:11, Norbert Hartl <[hidden email]> wrote: > > Is there any way to read a codepage 437 encoded file with pharo? > > thanks, > > Norbert This could be done with ZnByteEncoder, but that encoding is not provided by default. So you need to generate a new mapping method, luckily this can be done automagically: ZnByteEncoder generateByteToUnicodeSpec: 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT'. Put it on the class side and plug it in #mappingToIdentifiers and #initialize again. I guess you maybe could provide a one-shot instance, but I have never done that and adding it as known encoding will be easier at first. I am sure you will figure it out ;-) Let me know how it goes, maybe it would be a good idea to allow one-shot encoder instances based just on a spec from unicode.org Sven |
Excellent!
You rock sven! Le 20/10/15 14:22, Sven Van Caekenberghe a écrit : > Norbert, > >> On 20 Oct 2015, at 14:11, Norbert Hartl <[hidden email]> wrote: >> >> Is there any way to read a codepage 437 encoded file with pharo? >> >> thanks, >> >> Norbert > This could be done with ZnByteEncoder, but that encoding is not provided by default. So you need to generate a new mapping method, luckily this can be done automagically: > > ZnByteEncoder generateByteToUnicodeSpec: 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT'. > > Put it on the class side and plug it in #mappingToIdentifiers and #initialize again. I guess you maybe could provide a one-shot instance, but I have never done that and adding it as known encoding will be easier at first. > > I am sure you will figure it out ;-) > > Let me know how it goes, maybe it would be a good idea to allow one-shot encoder instances based just on a spec from unicode.org > > Sven > > > |
I added the following:
=== Name: Zinc-Character-Encoding-Core-SvenVanCaekenberghe.41 Author: SvenVanCaekenberghe Time: 20 October 2015, 6:35:23.106957 pm UUID: c6b0b265-827d-439b-b241-81bce4c56dc3 Ancestors: Zinc-Character-Encoding-Core-SvenVanCaekenberghe.40 Introduction of ZnByteEncoder class>>#newFromUrl: Refactoring introduced #top123FromUnicodeSpec: === Name: Zinc-Character-Encoding-Tests-SvenVanCaekenberghe.23 Author: SvenVanCaekenberghe Time: 20 October 2015, 6:36:04.004228 pm UUID: 265ff0e3-85df-47d2-8821-f9979aca15a0 Ancestors: Zinc-Character-Encoding-Tests-SvenVanCaekenberghe.22 Added ZnCharacterEncoderTests>>#testByteEncoderFromUrl === So now you can do ZnByteEncoder newFromUrl: 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT'. But you better cache that instance somewhere. Sven On 20 Oct 2015, at 16:07, stepharo <[hidden email]> wrote: > > > Excellent! > You rock sven! > > Le 20/10/15 14:22, Sven Van Caekenberghe a écrit : >> Norbert, >> >>> On 20 Oct 2015, at 14:11, Norbert Hartl <[hidden email]> wrote: >>> >>> Is there any way to read a codepage 437 encoded file with pharo? >>> >>> thanks, >>> >>> Norbert >> This could be done with ZnByteEncoder, but that encoding is not provided by default. So you need to generate a new mapping method, luckily this can be done automagically: >> >> ZnByteEncoder generateByteToUnicodeSpec: 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT'. >> >> Put it on the class side and plug it in #mappingToIdentifiers and #initialize again. I guess you maybe could provide a one-shot instance, but I have never done that and adding it as known encoding will be easier at first. >> >> I am sure you will figure it out ;-) >> >> Let me know how it goes, maybe it would be a good idea to allow one-shot encoder instances based just on a spec from unicode.org >> >> Sven >> >> >> > > |
Thanks Sven. I'll look into this soon and will provide feedback.
Norbert > Am 20.10.2015 um 18:38 schrieb Sven Van Caekenberghe <[hidden email]>: > > I added the following: > > === > Name: Zinc-Character-Encoding-Core-SvenVanCaekenberghe.41 > Author: SvenVanCaekenberghe > Time: 20 October 2015, 6:35:23.106957 pm > UUID: c6b0b265-827d-439b-b241-81bce4c56dc3 > Ancestors: Zinc-Character-Encoding-Core-SvenVanCaekenberghe.40 > > Introduction of ZnByteEncoder class>>#newFromUrl: > Refactoring introduced #top123FromUnicodeSpec: > === > Name: Zinc-Character-Encoding-Tests-SvenVanCaekenberghe.23 > Author: SvenVanCaekenberghe > Time: 20 October 2015, 6:36:04.004228 pm > UUID: 265ff0e3-85df-47d2-8821-f9979aca15a0 > Ancestors: Zinc-Character-Encoding-Tests-SvenVanCaekenberghe.22 > > Added ZnCharacterEncoderTests>>#testByteEncoderFromUrl > === > > So now you can do > > ZnByteEncoder newFromUrl: 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT'. > > But you better cache that instance somewhere. > > Sven > > On 20 Oct 2015, at 16:07, stepharo <[hidden email]> wrote: >> >> >> Excellent! >> You rock sven! >> >> Le 20/10/15 14:22, Sven Van Caekenberghe a écrit : >>> Norbert, >>> >>>> On 20 Oct 2015, at 14:11, Norbert Hartl <[hidden email]> wrote: >>>> >>>> Is there any way to read a codepage 437 encoded file with pharo? >>>> >>>> thanks, >>>> >>>> Norbert >>> This could be done with ZnByteEncoder, but that encoding is not provided by default. So you need to generate a new mapping method, luckily this can be done automagically: >>> >>> ZnByteEncoder generateByteToUnicodeSpec: 'http://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT'. >>> >>> Put it on the class side and plug it in #mappingToIdentifiers and #initialize again. I guess you maybe could provide a one-shot instance, but I have never done that and adding it as known encoding will be easier at first. >>> >>> I am sure you will figure it out ;-) >>> >>> Let me know how it goes, maybe it would be a good idea to allow one-shot encoder instances based just on a spec from unicode.org >>> >>> Sven >>> >>> >>> >> >> > > |
Free forum by Nabble | Edit this page |