Stream.st
changeset 24035 ed67960ad29d
parent 24031 46f45f402974
child 24148 0a40f4bca78d
equal deleted inserted replaced
24034:ba4c42171801 24035:ed67960ad29d
       
     1 "{ Encoding: utf8 }"
       
     2 
     1 "
     3 "
     2  COPYRIGHT (c) 1989 by Claus Gittinger
     4  COPYRIGHT (c) 1989 by Claus Gittinger
     3 	      All Rights Reserved
     5 	      All Rights Reserved
     4 
     6 
     5  This software is furnished under a license and may be used
     7  This software is furnished under a license and may be used
   218 
   220 
   219 isAbstract
   221 isAbstract
   220     ^ self == Stream
   222     ^ self == Stream
   221 ! !
   223 ! !
   222 
   224 
       
   225 
   223 !Stream methodsFor:'Compatibility-Dolphin'!
   226 !Stream methodsFor:'Compatibility-Dolphin'!
   224 
   227 
   225 display:someObject
   228 display:someObject
   226     "dolphin compatibility"
   229     "dolphin compatibility"
   227 
   230 
   228     "/ someObject printOn:self.
   231     "/ someObject printOn:self.
   229     self nextPutAll: someObject asString.
   232     self nextPutAll: someObject asString.
   230 ! !
   233 ! !
       
   234 
   231 
   235 
   232 !Stream methodsFor:'Compatibility-VW'!
   236 !Stream methodsFor:'Compatibility-VW'!
   233 
   237 
   234 commit
   238 commit
   235     "alias for flush -- ST80 compatibility"
   239     "alias for flush -- ST80 compatibility"
  1985         self nextPutUtf16Bytes:(aString at:idx) MSB:msb.
  1989         self nextPutUtf16Bytes:(aString at:idx) MSB:msb.
  1986     ].
  1990     ].
  1987 
  1991 
  1988     "
  1992     "
  1989         (#[] writeStream
  1993         (#[] writeStream
  1990             nextPutAllUtf16Bytes:'BÄxxx' MSB:true;
  1994             nextPutAllUtf16Bytes:'BÄxxx' MSB:true;
  1991             nextPutUtf16:(Character codePoint:16r10CCCC) MSB:true;
  1995             nextPutUtf16:(Character codePoint:16r10CCCC) MSB:true;
  1992             contents)
  1996             contents)
  1993    "
  1997    "
  1994 !
  1998 !
  1995 
  1999 
  2011     1 to:stringSize do:[:idx |
  2015     1 to:stringSize do:[:idx |
  2012         self nextPutUtf8:(string at:idx).
  2016         self nextPutUtf8:(string at:idx).
  2013     ].
  2017     ].
  2014 
  2018 
  2015     "
  2019     "
  2016         String streamContents:[:s|
  2020      String streamContents:[:s|
  2017             s nextPutAllUtf8:'hallo'
  2021          s nextPutAllUtf8:'hallo'
  2018         ].
  2022      ].
  2019 
  2023 
  2020         ByteArray streamContents:[:s|
  2024      ByteArray streamContents:[:s|
  2021             s nextPutAllUtf8:'hallo'
  2025          s nextPutAllUtf8:'hallo'
  2022         ].
  2026      ].
  2023 
  2027 
  2024         String streamContents:[:s|
  2028      String streamContents:[:s|
  2025             s nextPutAllUtf8:'abcdeäöüß' asUnicode32String
  2029          s nextPutAllUtf8:'abcdeäöüß' asUnicode32String
  2026         ].
  2030      ].
  2027 .
  2031 
  2028         ByteArray streamContents:[:s|
  2032      ByteArray streamContents:[:s|
  2029             s nextPutAllUtf8:'abcdeäöüß' asUnicode32String
  2033          s nextPutAllUtf8:'abcdeäöüß' asUnicode32String
  2030         ].
  2034      ].
  2031 
  2035 
  2032         '/tmp/bytes' asFilename writingFileDo:[:s|
  2036      '/tmp/bytes' asFilename writingFileDo:[:s|
  2033             s nextPutAllUtf8:'abcdeäöüß'
  2037          s nextPutAllUtf8:'abcdeäöüß'
  2034         ].
  2038      ].
  2035     "
  2039     "
  2036 
  2040 
  2037     "Modified (format): / 16-02-2017 / 20:28:52 / stefan"
  2041     "Modified (format): / 16-02-2017 / 20:28:52 / stefan"
       
  2042     "Modified (comment): / 02-04-2019 / 11:10:25 / Claus Gittinger"
  2038 !
  2043 !
  2039 
  2044 
  2040 nextPutByte:aByteValue
  2045 nextPutByte:aByteValue
  2041     "write a byte.
  2046     "write a byte.
  2042      Same as nextPut: here; for protocol compatibility with externalStream."
  2047      Same as nextPut: here; for protocol compatibility with externalStream."
  2459         ].
  2464         ].
  2460 
  2465 
  2461     "
  2466     "
  2462         ((WriteStream on:Unicode16String new)
  2467         ((WriteStream on:Unicode16String new)
  2463             nextPutUtf16:$B;
  2468             nextPutUtf16:$B;
  2464             nextPutUtf16:$Ä; 
  2469             nextPutUtf16:$Ä; 
  2465             nextPutUtf16:(Character codePoint:16r10CCCC)
  2470             nextPutUtf16:(Character codePoint:16r10CCCC)
  2466             yourself) contents
  2471             yourself) contents
  2467     "
  2472     "
  2468 !
  2473 !
  2469 
  2474 
  2494     ].
  2499     ].
  2495 
  2500 
  2496     "
  2501     "
  2497         (#[] writeStream
  2502         (#[] writeStream
  2498             nextPutUtf16Bytes:$B MSB:true;
  2503             nextPutUtf16Bytes:$B MSB:true;
  2499             nextPutUtf16Bytes:$Ä MSB:true;
  2504             nextPutUtf16Bytes:$Ä MSB:true;
  2500             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:true;
  2505             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:true;
  2501             contents)
  2506             contents)
  2502 
  2507 
  2503         ('' writeStream
  2508         ('' writeStream
  2504             nextPutUtf16Bytes:$B MSB:true;
  2509             nextPutUtf16Bytes:$B MSB:true;
  2505             nextPutUtf16Bytes:$Ä MSB:true;
  2510             nextPutUtf16Bytes:$Ä MSB:true;
  2506             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:true;
  2511             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:true;
  2507             contents)
  2512             contents)
  2508 
  2513 
  2509         (FileStream newTemporary
  2514         (FileStream newTemporary
  2510             nextPutUtf16Bytes:$B MSB:false;
  2515             nextPutUtf16Bytes:$B MSB:false;
  2511             nextPutUtf16Bytes:$Ä MSB:false;
  2516             nextPutUtf16Bytes:$Ä MSB:false;
  2512             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:false;
  2517             nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:false;
  2513             reset;
  2518             reset;
  2514             binary;
  2519             binary;
  2515             contents)
  2520             contents)
  2516     "
  2521     "
  2618     EncodingError raiseWith:aCharacter errorString:'codePoint > 31bit in #nextPutUtf8:'.
  2623     EncodingError raiseWith:aCharacter errorString:'codePoint > 31bit in #nextPutUtf8:'.
  2619 
  2624 
  2620     "
  2625     "
  2621       (String streamContents:[:s|
  2626       (String streamContents:[:s|
  2622             s nextPutUtf8:$a.
  2627             s nextPutUtf8:$a.
  2623             s nextPutUtf8:$ü.
  2628             s nextPutUtf8:$ü.
  2624             s nextPutUtf8: (Character value:16r1fff).
  2629             s nextPutUtf8: (Character value:16r1fff).
  2625             s nextPutUtf8: (Character value:16rffff).
  2630             s nextPutUtf8: (Character value:16rffff).
  2626             s nextPutUtf8: (Character value:16r1ffffff).
  2631             s nextPutUtf8: (Character value:16r1ffffff).
  2627             s nextPutUtf8: (Character value:16r800).
  2632             s nextPutUtf8: (Character value:16r800).
  2628       ])
  2633       ])