Stream.st
changeset 24031 46f45f402974
parent 23989 c34a416053bb
child 24035 ed67960ad29d
equal deleted inserted replaced
24030:4f1f0d4e1ce4 24031:46f45f402974
     1 "{ Encoding: utf8 }"
       
     2 
       
     3 "
     1 "
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     5 	      All Rights Reserved
     3 	      All Rights Reserved
     6 
     4 
     7  This software is furnished under a license and may be used
     5  This software is furnished under a license and may be used
   220 
   218 
   221 isAbstract
   219 isAbstract
   222     ^ self == Stream
   220     ^ self == Stream
   223 ! !
   221 ! !
   224 
   222 
   225 
       
   226 !Stream methodsFor:'Compatibility-Dolphin'!
   223 !Stream methodsFor:'Compatibility-Dolphin'!
   227 
   224 
   228 display:someObject
   225 display:someObject
   229     "dolphin compatibility"
   226     "dolphin compatibility"
   230 
   227 
   231     "/ someObject printOn:self.
   228     "/ someObject printOn:self.
   232     self nextPutAll: someObject asString.
   229     self nextPutAll: someObject asString.
   233 ! !
   230 ! !
   234 
       
   235 
   231 
   236 !Stream methodsFor:'Compatibility-VW'!
   232 !Stream methodsFor:'Compatibility-VW'!
   237 
   233 
   238 commit
   234 commit
   239     "alias for flush -- ST80 compatibility"
   235     "alias for flush -- ST80 compatibility"
  1989         self nextPutUtf16Bytes:(aString at:idx) MSB:msb.
  1985         self nextPutUtf16Bytes:(aString at:idx) MSB:msb.
  1990     ].
  1986     ].
  1991 
  1987 
  1992     "
  1988     "
  1993         (#[] writeStream
  1989         (#[] writeStream
  1994             nextPutAllUtf16Bytes:'BÄxxx' MSB:true;
  1990             nextPutAllUtf16Bytes:'BÄxxx' MSB:true;
  1995             nextPutUtf16:(Character codePoint:16r10CCCC) MSB:true;
  1991             nextPutUtf16:(Character codePoint:16r10CCCC) MSB:true;
  1996             contents)
  1992             contents)
  1997    "
  1993    "
  1998 !
  1994 !
  1999 
  1995 
  2024         ByteArray streamContents:[:s|
  2020         ByteArray streamContents:[:s|
  2025             s nextPutAllUtf8:'hallo'
  2021             s nextPutAllUtf8:'hallo'
  2026         ].
  2022         ].
  2027 
  2023 
  2028         String streamContents:[:s|
  2024         String streamContents:[:s|
  2029             s nextPutAllUtf8:'abcdeäöüß' asUnicode32String
  2025             s nextPutAllUtf8:'abcdeäöüß' asUnicode32String
  2030         ].
  2026         ].
  2031 .
  2027 .
  2032         ByteArray streamContents:[:s|
  2028         ByteArray streamContents:[:s|
  2033             s nextPutAllUtf8:'abcdeäöüß' asUnicode32String
  2029             s nextPutAllUtf8:'abcdeäöüß' asUnicode32String
  2034         ].
  2030         ].
  2035 
  2031 
  2036         '/tmp/bytes' asFilename writingFileDo:[:s|
  2032         '/tmp/bytes' asFilename writingFileDo:[:s|
  2037             s nextPutAllUtf8:'abcdeäöüß'
  2033             s nextPutAllUtf8:'abcdeäöüß'
  2038         ].
  2034         ].
  2039     "
  2035     "
  2040 
  2036 
  2041     "Modified (format): / 16-02-2017 / 20:28:52 / stefan"
  2037     "Modified (format): / 16-02-2017 / 20:28:52 / stefan"
  2042 !
  2038 !
  2463         ].
  2459         ].
  2464 
  2460 
  2465     "
  2461     "
  2466         ((WriteStream on:Unicode16String new)
  2462         ((WriteStream on:Unicode16String new)
  2467             nextPutUtf16:$B;
  2463             nextPutUtf16:$B;
  2468             nextPutUtf16:$Ä; 
  2464             nextPutUtf16:$Ä; 
  2469             nextPutUtf16:(Character codePoint:16r10CCCC)
  2465             nextPutUtf16:(Character codePoint:16r10CCCC)
  2470             yourself) contents
  2466             yourself) contents
  2471     "
  2467     "
  2472 !
  2468 !
  2473 
  2469 
  2498     ].
  2494     ].
  2499 
  2495 
  2500     "
  2496     "
  2501         (#[] writeStream
  2497         (#[] writeStream
  2502             nextPutUtf16Bytes:$B MSB:true;
  2498             nextPutUtf16Bytes:$B MSB:true;
  2503             nextPutUtf16Bytes:$Ä MSB:true;
  2499             nextPutUtf16Bytes:$Ä MSB:true;
  2504             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:true;
  2500             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:true;
  2505             contents)
  2501             contents)
  2506 
  2502 
  2507         ('' writeStream
  2503         ('' writeStream
  2508             nextPutUtf16Bytes:$B MSB:true;
  2504             nextPutUtf16Bytes:$B MSB:true;
  2509             nextPutUtf16Bytes:$Ä MSB:true;
  2505             nextPutUtf16Bytes:$Ä MSB:true;
  2510             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:true;
  2506             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:true;
  2511             contents)
  2507             contents)
  2512 
  2508 
  2513         (FileStream newTemporary
  2509         (FileStream newTemporary
  2514             nextPutUtf16Bytes:$B MSB:false;
  2510             nextPutUtf16Bytes:$B MSB:false;
  2515             nextPutUtf16Bytes:$Ä MSB:false;
  2511             nextPutUtf16Bytes:$Ä MSB:false;
  2516             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:false;
  2512             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:false;
  2517             reset;
  2513             reset;
  2518             binary;
  2514             binary;
  2519             contents)
  2515             contents)
  2520     "
  2516     "
  2622     EncodingError raiseWith:aCharacter errorString:'codePoint > 31bit in #nextPutUtf8:'.
  2618     EncodingError raiseWith:aCharacter errorString:'codePoint > 31bit in #nextPutUtf8:'.
  2623 
  2619 
  2624     "
  2620     "
  2625       (String streamContents:[:s|
  2621       (String streamContents:[:s|
  2626             s nextPutUtf8:$a.
  2622             s nextPutUtf8:$a.
  2627             s nextPutUtf8:$ü.
  2623             s nextPutUtf8:$ü.
  2628             s nextPutUtf8: (Character value:16r1fff).
  2624             s nextPutUtf8: (Character value:16r1fff).
  2629             s nextPutUtf8: (Character value:16rffff).
  2625             s nextPutUtf8: (Character value:16rffff).
  2630             s nextPutUtf8: (Character value:16r1ffffff).
  2626             s nextPutUtf8: (Character value:16r1ffffff).
  2631             s nextPutUtf8: (Character value:16r800).
  2627             s nextPutUtf8: (Character value:16r800).
  2632       ])
  2628       ])
  4308 
  4304 
  4309     "Modified: 11.7.1996 / 10:00:28 / cg"
  4305     "Modified: 11.7.1996 / 10:00:28 / cg"
  4310 !
  4306 !
  4311 
  4307 
  4312 nextPutAll:aCollection startingAt:first to:last
  4308 nextPutAll:aCollection startingAt:first to:last
  4313     "append the elements with index from first to last
  4309     "append the elements from first index to last index
  4314      of the argument, aCollection onto the receiver.
  4310      of the argument, aCollection onto the receiver.
  4315      This is only allowed, if the receiver supports writing."
  4311      This is only allowed, if the receiver supports writing."
  4316 
  4312 
  4317     aCollection from:first to:last do:[:element |
  4313     aCollection from:first to:last do:[:element |
  4318         self nextPut:element
  4314         self nextPut:element
  4326      s contents
  4322      s contents
  4327     "
  4323     "
  4328 
  4324 
  4329     "Modified: / 11-07-1996 / 10:00:32 / cg"
  4325     "Modified: / 11-07-1996 / 10:00:32 / cg"
  4330     "Modified: / 22-11-2018 / 12:52:25 / Stefan Vogel"
  4326     "Modified: / 22-11-2018 / 12:52:25 / Stefan Vogel"
       
  4327     "Modified (comment): / 01-04-2019 / 17:12:15 / Claus Gittinger"
  4331 !
  4328 !
  4332 
  4329 
  4333 nextPutAllLines:aCollectionOfStrings
  4330 nextPutAllLines:aCollectionOfStrings
  4334     "put all elements of the argument, aCollection as individual lines
  4331     "put all elements of the argument, aCollection as individual lines
  4335      onto the receiver, append a cr (carriage return) after each.
  4332      onto the receiver, append a cr (carriage return) after each.