[squeak-dev] The Trunk: Collections-pre.747.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Apr 20 09:37:18 UTC 2017
Patrick Rein uploaded a new version of Collections to project The Trunk:
http://source.squeak.org/trunk/Collections-pre.747.mcz
==================== Summary ====================
Name: Collections-pre.747
Author: pre
Time: 20 April 2017, 11:37:10.168994 am
UUID: 6fe02314-e789-064a-b678-0caec3506aac
Ancestors: Collections-eem.746
changes decoding of mime headers to decode directly to squeak encoding
=============== Diff against Collections-eem.746 ===============
Item was changed:
----- Method: String>>decodeMimeHeader (in category 'internet') -----
decodeMimeHeader
"See RFC 2047, MIME Part Three: Message Header Extension for Non-ASCII
+ Text and RFC 1342. Text containing non-ASCII characters is encoded by the sequence
- Text. Text containing non-ASCII characters is encoded by the sequence
=?character-set?encoding?encoded-text?=
Encoding is Q (quoted printable) or B (Base64), handled by
Base64MimeConverter / RFC2047MimeConverter.
Thanks to Yokokawa-san, it works in m17n package. Try the following:
'=?ISO-2022-JP?B?U1dJS0lQT1AvGyRCPUJDKyVpJXMlQRsoQi8=?= =?ISO-2022-JP?B?GyRCJVElRiUjJSobKEIoUGF0aW8p?=' decodeMimeHeader.
"
| input output temp charset decoder encodedStream encoding pos |
input := ReadStream on: self.
output := WriteStream on: String new.
[output
nextPutAll: (input upTo: $=).
"ASCII Text"
input atEnd]
whileFalse: [(temp := input next) = $?
ifTrue: [charset := input upTo: $?.
encoding := (input upTo: $?) asUppercase.
temp := input upTo: $?.
input next.
"Skip final ="
(charset isNil or: [charset size = 0]) ifTrue: [charset := 'LATIN-1'].
+ encodedStream := WriteStream on: String new.
- encodedStream := MultiByteBinaryOrTextStream on: String new encoding: charset.
decoder := encoding = 'B'
ifTrue: [Base64MimeConverter new]
ifFalse: [RFC2047MimeConverter new].
decoder
mimeStream: (ReadStream on: temp);
dataStream: encodedStream;
mimeDecode.
+
+ output nextPutAll: (MultiByteBinaryOrTextStream with: encodedStream contents encoding: charset) contents.
- output nextPutAll: encodedStream reset contents.
pos := input position.
input skipSeparators.
"Delete spaces if followed by ="
input peek = $=
ifFalse: [input position: pos]]
ifFalse: [output nextPut: $=;
nextPut: temp]].
^ output contents!
More information about the Squeak-dev
mailing list
|