Hilaire, On 12 May 2013, at 16:03, Hilaire Fernandes <hilaire.fernandes@gmail.com> wrote:
Hello,
I am using FTP Client to save xml file. Some of these files may be WideString, in that case the FTP Client fails. I got a ByteArray(Object)>>errorImproperStore
The code snippet to save is like this (client is ftp client) readonlyStream := ReadStream on: stream contents. client putFileStreamContents: readonlyStream as: aFilename
If I convert the content to ByteArray, in that case file is x4 times greater, which should not be the case.
Enclosed PharoDebug
Thanks
Hilaire
-- Dr. Geo http://drgeo.eu <PharoDebug.log>
I am not using FTP anymore, but from looking at the Smalltalk code of FTPClient it is clear that was written / expects binary data when doing uploads (hence you have to send it #binary as well), which js logical. That it worked before with Strings is because of a lucky accident in the SocketStream/VM internals (basically, it is as if #asByteArray is sent to it), but that comes down to a Latin1 encoding, more or less. If you send #asByteArray to a WideString, it does the wrong thing (just encode each Unicode code point as 32 bit integers). You need to do proper encoding. For example, to do UTF8 encoding, try: ZnUTF8Encoder new encodeString: 'élève en Français'. HTH, Sven -- Sven Van Caekenberghe Proudly supporting Pharo http://pharo.org http://association.pharo.org http://consortium.pharo.org