CharacterEncoderImplementations__ISO10646_to_UTF8.st
branchjv
changeset 18608 7d521f25267c
parent 18120 e3a375d5f6a8
parent 18601 00dc53dfe54d
child 18610 b9799e74a9c5
equal deleted inserted replaced
18571:8c6ab490b982 18608:7d521f25267c
    72      ascii "{ Class: SmallInteger }"
    72      ascii "{ Class: SmallInteger }"
    73      byte  "{ Class: SmallInteger }"
    73      byte  "{ Class: SmallInteger }"
    74      s newString idx next6Bits last6Bits
    74      s newString idx next6Bits last6Bits
    75      errorReporter|
    75      errorReporter|
    76 
    76 
    77     "/ avoid creation of new strings
    77     "/ fast track, also avoid creation of new strings if aStringOrByteCollection is already a 7-bit string
    78     aStringOrByteCollection isString ifTrue:[
    78     aStringOrByteCollection containsNon7BitAscii ifFalse:[
    79         aStringOrByteCollection contains8BitCharacters ifFalse:[^ aStringOrByteCollection].
    79         ^ aStringOrByteCollection asSingleByteString
    80     ].
    80     ].
    81 
    81 
    82     errorReporter := [:msg | 
    82     errorReporter := [:msg | 
    83                              DecodingError newException
    83                              DecodingError newException
    84                                 defaultValue:aStringOrByteCollection;
    84                                 defaultValue:aStringOrByteCollection;
   310      this is a first-class candidate for a primitive."
   310      this is a first-class candidate for a primitive."
   311 
   311 
   312     |s|
   312     |s|
   313 
   313 
   314     "/ avoid creation of new strings
   314     "/ avoid creation of new strings
   315     aUnicodeString contains8BitCharacters ifFalse:[^ aUnicodeString asSingleByteString].
   315     aUnicodeString containsNon7BitAscii ifFalse:[
       
   316         ^ aUnicodeString asSingleByteString
       
   317     ].
   316 
   318 
   317     s := WriteStream on:(String uninitializedNew:aUnicodeString size).
   319     s := WriteStream on:(String uninitializedNew:aUnicodeString size).
   318     aUnicodeString do:[:eachCharacter |
   320     aUnicodeString do:[:eachCharacter |
   319         |codePoint "{Class: SmallInteger }" b1 b2 b3 b4 b5 v "{Class: SmallInteger }"|
   321         |codePoint "{Class: SmallInteger }" b1 b2 b3 b4 b5 v "{Class: SmallInteger }"|
   320 
   322 
   458 ! !
   460 ! !
   459 
   461 
   460 !ISO10646_to_UTF8 class methodsFor:'documentation'!
   462 !ISO10646_to_UTF8 class methodsFor:'documentation'!
   461 
   463 
   462 version
   464 version
   463     ^ '$Header: /cvs/stx/stx/libbasic/CharacterEncoderImplementations__ISO10646_to_UTF8.st,v 1.19 2015-03-14 21:33:29 stefan Exp $'
   465     ^ '$Header$'
   464 ! !
   466 ! !
   465 
   467