1: <?php
2:
3: class Swift_Mime_ContentEncoder_NativeQpContentEncoder implements Swift_Mime_ContentEncoder
4: {
5: /**
6: * Notify this observer that the entity's charset has changed.
7: * @param string $charset
8: */
9: public function charsetChanged($charset)
10: {
11: if ($charset !== 'utf-8') {
12: throw new RuntimeException(
13: sprintf('Charset "%s" not supported. NativeQpContentEncoder only supports "utf-8"', $charset));
14: }
15: }
16:
17: /**
18: * Encode $in to $out.
19: * @param Swift_OutputByteStream $os to read from
20: * @param Swift_InputByteStream $is to write to
21: * @param int $firstLineOffset
22: * @param int $maxLineLength - 0 indicates the default length for this encoding
23: */
24: public function encodeByteStream(
25: Swift_OutputByteStream $os, Swift_InputByteStream $is, $firstLineOffset = 0,
26: $maxLineLength = 0)
27: {
28: $string = '';
29:
30: while (false !== $bytes = $os->read(8192)) {
31: $string .= $bytes;
32: }
33:
34: $is->write($this->encodeString($string));
35: }
36:
37: /**
38: * Get the MIME name of this content encoding scheme.
39: * @return string
40: */
41: public function getName()
42: {
43: return 'quoted-printable';
44: }
45:
46: /**
47: * Encode a given string to produce an encoded string.
48: * @param string $string
49: * @param int $firstLineOffset if first line needs to be shorter
50: * @param int $maxLineLength - 0 indicates the default length for this encoding
51: * @return string
52: */
53: public function encodeString($string, $firstLineOffset = 0,
54: $maxLineLength = 0)
55: {
56: return quoted_printable_encode($string);
57: }
58: }
59: