TwoByteString.st
branchjv
changeset 19863 513bd7237fe7
parent 19811 65fec19facb0
parent 19840 8f332a47d6c9
child 23547 c69c97cec351
equal deleted inserted replaced
19862:6c010853ea32 19863:513bd7237fe7
   111 
   111 
   112 unsignedShortAt:index
   112 unsignedShortAt:index
   113     "return the short at position index, an Integer"
   113     "return the short at position index, an Integer"
   114 
   114 
   115     ^ super basicAt:index.
   115     ^ super basicAt:index.
   116 ! !
       
   117 
       
   118 !TwoByteString methodsFor:'encoding'!
       
   119 
       
   120 utf8Encoded
       
   121     "Return my UTF-8 representation as a new String"
       
   122 
       
   123     ^ CharacterEncoderImplementations::ISO10646_to_UTF8 new encodeString:self
       
   124 
       
   125 
       
   126     "
       
   127         'abcdef' asUnicode16String utf8Encoded
       
   128         'abcdefäöü' asUnicode16String utf8Encoded
       
   129     "
       
   130 !
       
   131 
       
   132 utf8EncodedOn:aStream
       
   133     "write to aStream in utf8 encoding"
       
   134 
       
   135     self containsNon7BitAscii ifTrue:[
       
   136         aStream nextPutAllUtf8:self.
       
   137     ] ifFalse:[
       
   138         |sz "{Class: SmallInteger}"|
       
   139 
       
   140         sz := self size.
       
   141         1 to:sz do:[:idx|
       
   142             aStream nextPut:(self basicAt:idx).
       
   143         ].
       
   144     ].
       
   145 
       
   146     "
       
   147      String streamContents:[:w|
       
   148         'abcde1234' asUnicode16String utf8EncodedOn:w
       
   149      ].
       
   150      String streamContents:[:w|
       
   151          'abcdeäöüß' asUnicode16String utf8EncodedOn:w
       
   152      ].
       
   153     "
       
   154 ! !
   116 ! !
   155 
   117 
   156 !TwoByteString methodsFor:'filling and replacing'!
   118 !TwoByteString methodsFor:'filling and replacing'!
   157 
   119 
   158 replaceFrom:start to:stop with:aString startingAt:repStart
   120 replaceFrom:start to:stop with:aString startingAt:repStart