/src/lib/io/filter/quoted_printable_output_stream.e

http://github.com/tybor/Liberty · Specman e · 68 lines · 35 code · 7 blank · 26 comment · 0 complexity · ce719dfafa66499029a29fd2c0538b93 MD5 · raw file

  1. -- This file is part of a Liberty Eiffel library.
  2. -- See the full copyright at the end.
  3. --
  4. class QUOTED_PRINTABLE_OUTPUT_STREAM
  5. --
  6. -- A quoted-printable encoder. The underlying stream gets encoded in quoted-printable via this filter.
  7. --
  8. inherit
  9. FILTER_OUTPUT_STREAM
  10. create {ANY}
  11. connect_to
  12. feature {}
  13. local_can_disconnect: BOOLEAN True
  14. feature {FILTER_OUTPUT_STREAM}
  15. filtered_put_character (c: CHARACTER)
  16. do
  17. inspect
  18. c.code
  19. when 0 .. 9, 11 .. 31, 128 .. 255 then
  20. put_quoted_character(c)
  21. else
  22. stream.filtered_put_character(c)
  23. end
  24. end
  25. filtered_flush
  26. do
  27. stream.filtered_flush
  28. end
  29. feature {}
  30. put_quoted_character (c: CHARACTER)
  31. local
  32. s: STRING
  33. do
  34. s := once ""
  35. s.clear_count
  36. c.code.to_hexadecimal_in(s)
  37. stream.filtered_put_character('=')
  38. stream.filtered_put_character(s.item(s.upper - 1))
  39. stream.filtered_put_character(s.last)
  40. end
  41. end -- class QUOTED_PRINTABLE_OUTPUT_STREAM
  42. --
  43. -- Copyright (C) 2009-2017: by all the people cited in the AUTHORS file.
  44. --
  45. -- Permission is hereby granted, free of charge, to any person obtaining a copy
  46. -- of this software and associated documentation files (the "Software"), to deal
  47. -- in the Software without restriction, including without limitation the rights
  48. -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  49. -- copies of the Software, and to permit persons to whom the Software is
  50. -- furnished to do so, subject to the following conditions:
  51. --
  52. -- The above copyright notice and this permission notice shall be included in
  53. -- all copies or substantial portions of the Software.
  54. --
  55. -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  56. -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  57. -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  58. -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  59. -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  60. -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  61. -- THE SOFTWARE.