#DOCUMENTATION by stefan
class: Stream
comment/format in: #nextPutUtf16Bytes:MSB:
--- a/Stream.st Tue Jan 16 23:21:54 2018 +0100
+++ b/Stream.st Tue Jan 16 23:22:28 2018 +0100
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -2045,7 +2047,7 @@
"
(#[] writeStream
- nextPutAllUtf16Bytes:'BÄxxx' MSB:true;
+ nextPutAllUtf16Bytes:'BÃxxx' MSB:true;
nextPutUtf16:(Character codePoint:16r10CCCC) MSB:true;
contents)
"
@@ -2080,15 +2082,15 @@
].
String streamContents:[:s|
- s nextPutAllUtf8:'abcdeäöüß' asUnicode32String
+ s nextPutAllUtf8:'abcdeäöüÃ' asUnicode32String
].
.
ByteArray streamContents:[:s|
- s nextPutAllUtf8:'abcdeäöüß' asUnicode32String
+ s nextPutAllUtf8:'abcdeäöüÃ' asUnicode32String
].
'/tmp/bytes' asFilename writingFileDo:[:s|
- s nextPutAllUtf8:'abcdeäöüß'
+ s nextPutAllUtf8:'abcdeäöüÃ'
].
"
@@ -2499,7 +2501,7 @@
"
((WriteStream on:Unicode16String new)
nextPutUtf16:$B;
- nextPutUtf16:$Ä;
+ nextPutUtf16:$Ã;
nextPutUtf16:(Character codePoint:16r10CCCC)
yourself) contents
"
@@ -2513,48 +2515,47 @@
|codePoint "{ Class: SmallInteger }"|
codePoint := aCharacter codePoint.
- (codePoint <= 16rD7FF or:[ codePoint between:16rE000 and:16rFFFF ])
- ifTrue:[
- self nextPutInt16:codePoint MSB:msb.
+ (codePoint <= 16rD7FF or:[codePoint between:16rE000 and:16rFFFF]) ifTrue:[
+ self nextPutInt16:codePoint MSB:msb.
+ ] ifFalse:[
+ codePoint <= 16r10FFFF ifTrue:[
+ |highBits lowBits|
+
+ codePoint := codePoint - 16r100000.
+ highBits := codePoint bitShift:-10.
+ lowBits := codePoint bitAnd:16r3FF.
+ self nextPutInt16:(highBits + 16rD800) MSB:msb.
+ self nextPutInt16:(lowBits + 16rDC00) MSB:msb.
+ ] ifFalse:[
+ EncodingError
+ raiseWith:aCharacter
+ errorString:'Character cannot be encoded as UTF-16'.
]
- ifFalse:[
- codePoint <= 16r10FFFF ifTrue:[
- |highBits lowBits|
-
- codePoint := codePoint - 16r100000.
- highBits := codePoint bitShift:-10.
- lowBits := codePoint bitAnd:16r3FF.
- self nextPutInt16:(highBits + 16rD800) MSB:msb.
- self nextPutInt16:(lowBits + 16rDC00) MSB:msb.
- ] ifFalse:[
- EncodingError raiseWith:aCharacter
- errorString:'Character cannot be encoded as UTF-16'.
- ]
- ].
+ ].
"
(#[] writeStream
nextPutUtf16Bytes:$B MSB:true;
- nextPutUtf16Bytes:$Ä MSB:true;
+ nextPutUtf16Bytes:$Ã MSB:true;
nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:true;
contents)
('' writeStream
nextPutUtf16Bytes:$B MSB:true;
- nextPutUtf16Bytes:$Ä MSB:true;
+ nextPutUtf16Bytes:$Ã MSB:true;
nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:true;
contents)
(FileStream newTemporary
nextPutUtf16Bytes:$B MSB:false;
- nextPutUtf16Bytes:$Ä MSB:false;
+ nextPutUtf16Bytes:$Ã MSB:false;
nextPutUtf16Bytes:(Character codePoint:16r10CCCC) MSB:false;
reset;
binary;
contents)
"
- "Modified (comment): / 16-02-2017 / 17:02:55 / stefan"
+ "Modified (format): / 16-01-2018 / 19:41:27 / stefan"
!
nextPutUtf8:aCharacter
@@ -2659,7 +2660,7 @@
"
(String streamContents:[:s|
s nextPutUtf8:$a.
- s nextPutUtf8:$ü.
+ s nextPutUtf8:$ü.
s nextPutUtf8: (Character value:16r1fff).
s nextPutUtf8: (Character value:16rffff).
s nextPutUtf8: (Character value:16r1ffffff).