Base64Coder.st
changeset 1415 3ef6a2c42611
parent 1391 530a5924e319
child 1442 7a149950485d
equal deleted inserted replaced
1414:e801d1248f10 1415:3ef6a2c42611
   132 
   132 
   133     "64 characters representing the 6-bit values from 0-63 and one pad character"
   133     "64 characters representing the 6-bit values from 0-63 and one pad character"
   134     Base64Mapping := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.
   134     Base64Mapping := 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='.
   135     Base64ReverseMapping := ByteArray new:256 withAll:255.
   135     Base64ReverseMapping := ByteArray new:256 withAll:255.
   136     Base64Mapping keysAndValuesDo:[:idx :char|
   136     Base64Mapping keysAndValuesDo:[:idx :char|
   137         Base64ReverseMapping at:char asciiValue put:idx-1.
   137         Base64ReverseMapping at:char codePoint put:idx-1.
   138     ].
   138     ].
   139 
   139 
   140     "
   140     "
   141      self initialize
   141      self initialize
   142     "
   142     "
   187             b := stream next.
   187             b := stream next.
   188             b isNil ifTrue:[ "end of stream"
   188             b isNil ifTrue:[ "end of stream"
   189                 atEnd := true.
   189                 atEnd := true.
   190                 ^ self.
   190                 ^ self.
   191             ].
   191             ].
   192             b := Base64ReverseMapping at:b asciiValue.
   192             b := Base64ReverseMapping at:b codePoint.
   193         ] doWhile:[b == 255].
   193         ] doWhile:[b == 255].
   194 
   194 
   195         b == 64 ifTrue:[
   195         b == 64 ifTrue:[
   196             "got #=, end of Base64 string has been reached"
   196             "got #=, end of Base64 string has been reached"
   197             atEnd := true.
   197             atEnd := true.
   417 ! !
   417 ! !
   418 
   418 
   419 !Base64Coder class methodsFor:'documentation'!
   419 !Base64Coder class methodsFor:'documentation'!
   420 
   420 
   421 version
   421 version
   422     ^ '$Header: /cvs/stx/stx/libbasic2/Base64Coder.st,v 1.11 2004-01-16 14:39:53 cg Exp $'
   422     ^ '$Header: /cvs/stx/stx/libbasic2/Base64Coder.st,v 1.12 2004-03-05 19:02:42 stefan Exp $'
   423 ! !
   423 ! !
   424 
   424 
   425 Base64Coder initialize!
   425 Base64Coder initialize!