Opened 11 years ago

Closed 9 years ago

#5624 closed Bugs (fixed)

base64 encode/decode

Reported by: nen777w@… Owned by: Robert Ramey
Milestone: To Be Determined Component: serialization
Version: Boost 1.45.0 Severity: Problem
Keywords: Cc:

Description

//typedefs
typedef boost::archive::iterators::istream_iterator<char> boost_istream_iterator;
typedef boost::archive::iterators::ostream_iterator<char> boost_ostream_iterator;

typedef boost::archive::iterators::insert_linebreaks<
	boost::archive::iterators::base64_from_binary<
		boost::archive::iterators::transform_width<boost_istream_iterator, 6, 8>
	>, 76
> bin_to_base64;

typedef boost::archive::iterators::transform_width<
	boost::archive::iterators::binary_from_base64<
		boost::archive::iterators::remove_whitespace<boost_istream_iterator>
	>, 8, 6
> base64_to_bin;

void test()
{
	{
		std::ifstream ifs("test.a", std::ios_base::in|std::ios_base::binary);
		std::ofstream ofs("test.b", std::ios_base::out|std::ios_base::binary);

		std::copy(
			bin_to_base64(boost_istream_iterator(ifs >> std::noskipws)),
			bin_to_base64(boost_istream_iterator()),
			boost_ostream_iterator(ofs)
		);
	}

	{
		std::ifstream ifs("test.b", std::ios_base::in|std::ios_base::binary);
		std::ofstream ofs("test.c", std::ios_base::out|std::ios_base::binary);

		std::copy(
			base64_to_bin(boost_istream_iterator(ifs >> std::noskipws)),
			base64_to_bin(boost_istream_iterator()),
			boost_ostream_iterator(ofs)
		);

	}
}

File test.a contain only one byte 0x50 'P'. Exception happen during decoding, the same behaviour repeat for a any ZIP file. For example. Instead file test.a use any valid zip file.

Change History (8)

comment:1 by anonymous, 11 years ago

File test.a contain only one byte 0x50 'P'. Exception happen during decoding, the same behaviour repeated for a any ZIP file. For example. Use instead file test.a any valid zip file.

comment:2 by nen777w@…, 11 years ago

If it may help. The workaround code and example how to use you can find here: http://rsdn.ru/forum/cpp.applied/4317966.1.aspx

comment:3 by Dave Abrahams, 10 years ago

Owner: changed from Dave Abrahams to jeffrey.hellrung

comment:4 by Robert Ramey, 10 years ago

Owner: changed from jeffrey.hellrung to Robert Ramey
Status: newassigned

comment:5 by Dave Abrahams, 10 years ago

Owner: changed from Robert Ramey to jeffrey.hellrung
Status: assignednew

comment:6 by Dave Abrahams, 10 years ago

Component: iteratorserialization
Owner: changed from jeffrey.hellrung to Robert Ramey

comment:7 by Robert Ramey, 9 years ago

Is this still an issue. I think I addressed this. Note that the test_iterators_base64 explicitly tests the situation where the number of characters to be rendered is only 1. Please double check and let me know. If I don't get any response for a while, I'll close this ticket.

Robert Ramey

comment:8 by Robert Ramey, 9 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.