[Pharo-project] Write accentuate characters in file

Norbert Hartl norbert at hartl.name
Mon May 16 19:38:54 CEST 2011


Am 16.05.2011 um 19:06 schrieb Toon Verwaest:

> You could also be friendly and tell the editor that it's UTF8 using a bom
> http://en.wikipedia.org/wiki/Byte_order_mark
> 
> I dunno how standard that is nowadays though.
> 
BOM is explicitly optional. One reason is the be sort of backward compatible for older programs. And this is because utf-8 is relatively close to latin1. etc.

My personal opinion is that a BOM does not solve the real problems. It is an endless story with stupid things and very good reasons for the stupid things to be there. E.g. If you have a utf-8 file on linux and on Mac they differ by design. Linux uses composed characters and Mac uses decomposed. If you are in latin1 character set this easily can drive you nuts.

Norbert

> On 05/16/2011 05:10 PM, Damien Cassou wrote:
>> On Mon, May 16, 2011 at 5:01 PM, Henrik Sperre Johansen
>> <henrik.s.johansen at veloxit.no>  wrote:
>>> FileStream newFileNamed: 'test.txt' do: [ :stream |
>>>     stream converter: MacRomanTextConverter new; " or: TextConverter
>>> newForEncoding: 'mac-roman' "
>>>     nextPutAll: 'ééé' ].
>> This is the correct way of solving your problem... however, your
>> application becomes dependent of MacOS X. If you want your application
>> to be portable to other OSes, I would advise you to use the simple
>> approach that you give
>> 
>> FileStream newFileNamed: 'test.txt' do: [ :each | each nextPutAll: 'ééé' ]
>> 
>> and tell your favorite Apple editor that this is indeed UTF-8. UTF-8
>> is the standard, MacRoman is Apple only.
>> 
> 
> 




More information about the Pharo-project mailing list