Jimmie Houchin-5 wrote > I still do not know how to do this correctly. But I have something that > seems to work for the moment. > > Using #asUTF8Bytes > > f nextPutAll: (writer write contents asUTF8Bytes). > > Now the file is in UTF-8 and normal size.
openForWriteFileNamed: opens a binary stream (... which incidentally, also lets you put strings/widestrings as if they were bytes/doublewords), to write string source as utf8, the best way is to wrap it in a stream which converts strings -> utf8 bytes, an example: binaryStream := (ByteArray new: 100) writeStream. encodedStream := ZnCharacterWriteStream on: binaryStream encoding: #utf8. encodedStream nextPutAll: '€'. binaryStream contents The "best"* way is to use an API which provides an encoded stream with scoped use (so you don't have to close it manually); for instance: '/home/jimmie/xmldoc.xml' asFileReference writeStreamDo: [ :ws | ws nextPutAll: writer write contents ] should default to a file stream outputting utf8. Cheers, Henry *May or may not work in Pharo 7 though, seeing as how the old default encoded stream has been deprecated, I haven't checked. -- Sent from: http://forum.world.st/Pharo-Smalltalk-Users-f1310670.html