FWIW, the discussion of EncodedStreams in doc/BasicLibraries.pdf has been updated recently. It might help with understanding the encoding process.
HTH, Martin "Dziedzic, Peter"<[hidden email]> wrote: > Hello, > > I open my socket with the following code: > > | host port connection | > ... > > host := 'localhost'. > > "Try to get port from services-file of the pc. > if not then use default-value" > Signal errorSignal handle: > [:ex | > Transcript > show: ex description; > cr. > port := 49700] > do: [ > port := IPSocketAddress servicePortByName: > 'TestSocket']. > > Signal errorSignal handle: > [:ex | > Transcript > show: 'socket connection failed'; > cr. > ^false] > do: > ["Create a socket on the given host and port." > > socket := SocketAccessor newTCPclientToHost: host > port: (port)]. "Open a > two-way connection on the socket." > connection := ExternalConnection new. > connection > input: socket; > output: socket. "Open a stream on the socket connection." > stream := connection readAppendStream. > ... > > Mit freundlichen Grüßen - best regards, > > Peter Dziedzic > > -------------------------------------- > > Carl Zeiss Industrielle Meßtechnik GmbH/ Industrial Metrology > Softwareentwicklung/Software Development > > P e t e r D z i e d z i c > > 73446 Oberkochen, Germany > > tel: +49 73 64 20-84 48 > fax: +49 73 64 20-48 00 > e-mail: [hidden email] > http://www.zeiss.de/imt > > Carl Zeiss Industrielle Messtechnik GmbH > Carl-Zeiss-Straße 22, 73447 Oberkochen > Aufsichtsratsvorsitzender: Dr. Dieter Kurz > Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Hanspeter Mürle > Sitz der Gesellschaft: 73446 Oberkochen, Deutschland > Amtsgericht Ulm, HRB 501561, USt-IdNr.: DE 811 515 346 > > > > > > > "Steven Kelly" <[hidden email]> > Gesendet von: [hidden email] > 25.02.2010 10:58 > > An > "Dziedzic, Peter" <[hidden email]> > Kopie > <[hidden email]> > Thema > RE: [vwnc] Antwort: AW: ascii-socket problem with umlaut > > > > > > > That might work, but it’s not right :-). #asByteString will try to read > the UTF-8 bytes as if they were ISO-8859-1 bytes; in this case that may > succeed, but in general you shouldn’t try to read with a different > encoding than you used when writing: it will often give errors, because > not all sequences of bytes are legal in all encodings. > > You need to change the encoding of the socket stream, which will mean that > when you send a Ü character, it is automatically converted into the right > sequence of UTF-8 bytes. You can supply the encoding to the socket when > you create it. If the code I sent before: > readStream := (aSocket asExternalConnection withEncoding: #'UTF-8') > readStream lineEndCRLF > doesn’t look similar enough to how you’re currently opening your socket > stream, tell us the code you are using and we’ll tell you where to add the > encoding command. > > Steve > > From: [hidden email] [mailto:[hidden email]] On Behalf > Of Dziedzic, Peter > Sent: 25 February 2010 11:40 > To: Georg Heeg > Cc: [hidden email] > Subject: [vwnc] Antwort: AW: ascii-socket problem with umlaut > > > Hello, > > the default-encoder in my smalltalk-application is #ISO8859_1 ( 'Ü' > stringEncoding streamEncodingType ). > > Do i have to convert the string with the following code in my smalltalk > enviroment to utf8? > > stringToSend := (stringToSend asByteArrayEncoding:#utf8) asByteString > > Is this correct for the smalltalk side? > > Mit freundlichen Grüßen - best regards, > > Peter Dziedzic > > -------------------------------------- > > Carl Zeiss Industrielle Meßtechnik GmbH/ Industrial Metrology > Softwareentwicklung/Software Development > > P e t e r D z i e d z i c > > 73446 Oberkochen, Germany > > tel: +49 73 64 20-84 48 > fax: +49 73 64 20-48 00 > e-mail: [hidden email] > http://www.zeiss.de/imt > > Carl Zeiss Industrielle Messtechnik GmbH > Carl-Zeiss-Straße 22, 73447 Oberkochen > Aufsichtsratsvorsitzender: Dr. Dieter Kurz > Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Hanspeter Mürle > Sitz der Gesellschaft: 73446 Oberkochen, Deutschland > Amtsgericht Ulm, HRB 501561, USt-IdNr.: DE 811 515 346 > > > > > > "Georg Heeg" <[hidden email]> > Gesendet von: [hidden email] > 25.02.2010 09:12 > > > An > "'Dziedzic, Peter'" <[hidden email]>, "'VWNC'" <[hidden email]> > Kopie > > Thema > AW: [vwnc] ascii-socket problem with umlaut > > > > > > > > > > Peter, > > Last Sunday I commented in this list in an email entitled “Postgres > 'ERROR: invalid byte sequence for encoding "UTF8": 0xe97269” > about the same problem. Thus here you’ll find only a short version: > > Sockets provide a communication as a sequence of bytes. Thus characters > (in Smalltalk Strings are sequences of Character objects) are encoded as > bytes using en encoder. In your code the default encoder is implicitly > used. I can only guess that this encoder might be UTF-8 or MSCP1252 or > ISO8859-L1. You can find out easily by debugging the Smalltalk expression. > > I have no idea about the C# side. I guess C# is using MSCP1252 or UTF16. > > What I would do? > 1. Find out which encoder what side uses > 2. Adapt both sides to use the same encoder explicitly > 3. As your application is used world-wide, I would rather prefer > UFT-8 (if most of your customers are using Latin character sets) or UTF16 > otherwise. > > Georg > > PS: The character set ASCII you mention in the subject line cannot encode > umlauts at all. > > Georg Heeg eK, Dortmund und Köthen, HR Dortmund A 12812 > Tel. +49-3496-214328, Fax +49-3496-214712 > Von: [hidden email] [mailto:[hidden email]] Im Auftrag > von Dziedzic, Peter > Gesendet: Donnerstag, 25. Februar 2010 08:54 > An: VWNC > Betreff: [vwnc] ascii-socket problem with umlaut > > > Hello, > > i have a problem with my ascii socket when i send german "Umlaute": e.g. Ü > Ö Ä. > > I have a smalltalk application that communicates with a C#-appliacation > over a Ascii-Socket. > > In Smalltalk i use stream nextPutAll: aString; and stream nextLine. > In C# I use sr = new StreamReader(stream);withsr.ReadLineand > sw = newStreamWriter(stream); with sw.WriteLine. > > How can i fix this problem? Is the problem the smalltalk or the C#-side? > > Mit freundlichen Grüßen - best regards, > > Peter Dziedzic > > -------------------------------------- > > Carl Zeiss Industrielle Meßtechnik GmbH/ Industrial Metrology > Softwareentwicklung/Software Development > > P e t e r D z i e d z i c > > 73446 Oberkochen, Germany > > tel: +49 73 64 20-84 48 > fax: +49 73 64 20-48 00 > e-mail: [hidden email] > http://www.zeiss.de/imt > > Carl Zeiss Industrielle Messtechnik GmbH > Carl-Zeiss-Straße 22, 73447 Oberkochen > Aufsichtsratsvorsitzender: Dr. Dieter Kurz > Geschäftsführer: Dr. Rainer Ohnheiser, Felix Hoben, Hanspeter Mürle > Sitz der Gesellschaft: 73446 Oberkochen, Deutschland > Amtsgericht Ulm, HRB 501561, USt-IdNr.: DE 811 515 346 > > > > > ---------------------------------------- > This message is intended for a particular addressee only and may contain > business or company secrets. If you have received this email in error, > please contact the sender and delete the message immediately. Any use of > this email, including saving, publishing, copying, replication or > forwarding of the message or the contents is not permitted. > > > ---------------------------------------- > This message is intended for a particular addressee only and may contain > business or company secrets. If you have received this email in error, > please contact the sender and delete the message immediately. Any use of > this email, including saving, publishing, copying, replication or > forwarding of the message or the contents is not permitted. > > > > > ---------------------------------------- > This message is intended for a particular addressee only and may contain business or company secrets. If you have received this email in error, please contact the sender and delete the message immediately. Any use of this email, including saving, publishing, copying, replication or forwarding of the message or the contents is not permitted. > > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |