base64_from_binary Q
I am using this sample to prove myself that base64_from_binary and
binary_from_base64 can be used in my app. But I am having little problem
and not able to understand whats missing
Here is the sample
#include "boost/archive/iterators/base64_from_binary.hpp"
#include "boost/archive/iterators/binary_from_base64.hpp"
#include "boost/archive/iterators/transform_width.hpp"
#include <string>
#include <iostream>
using namespace std;
using namespace boost::archive::iterators;
typedef
base64_from_binary<
transform_width
base64_t;
typedef transform_width< binary_from_base64std::string::iterator, sizeof(char) * 8, 6
binary_t;
int main() { string str = "Hello, world!"; cout << str << endl; string enc(base64_t(str.begin()), base64_t(str.end())); // Problem here. It works when I specify "str.end()-1" instead of "str.end()" but I loose last character after decoding. cout << enc << endl; string dec(binary_t(enc.begin()), binary_t(enc.end())); cout << dec << endl; return 0; } Will appreciate any help. I tried std::copy as well and have same problem.
I reported this problem a few months ago - apparently it is a feature
that this only works on input data that is a multiple of 3 bytes long
Andrew
From: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] On Behalf Of Terdale,
Shantibhushan
Sent: Tuesday, August 26, 2008 12:16 PM
To: boost-users@lists.boost.org
Subject: [Boost-users] base64_from_binary Q
I am using this sample to prove myself that base64_from_binary and
binary_from_base64 can be used in my app. But I am having little problem
and not able to understand whats missing
Here is the sample
#include "boost/archive/iterators/base64_from_binary.hpp"
#include "boost/archive/iterators/binary_from_base64.hpp"
#include "boost/archive/iterators/transform_width.hpp"
#include <string>
#include <iostream>
using namespace std;
using namespace boost::archive::iterators;
typedef
base64_from_binary<
transform_width
base64_t;
typedef transform_width< binary_from_base64std::string::iterator, sizeof(char) * 8, 6
binary_t;
int main() { string str = "Hello, world!"; cout << str << endl; string enc(base64_t(str.begin()), base64_t(str.end())); // Problem here. It works when I specify "str.end()-1" instead of "str.end()" but I loose last character after decoding. cout << enc << endl; string dec(binary_t(enc.begin()), binary_t(enc.end())); cout << dec << endl; return 0; } Will appreciate any help. I tried std::copy as well and have same problem.
Is there any possibility that we can extend this and use it for any
data?
Also does anyone know where is the documentation for both
transform_width and base64 iterator where I can find their usage? I
struggled a lot to get this example working.
________________________________
From: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] On Behalf Of Eames, Andrew
Sent: Tuesday, August 26, 2008 1:48 PM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] base64_from_binary Q
I reported this problem a few months ago - apparently it is a feature
that this only works on input data that is a multiple of 3 bytes long
Andrew
From: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] On Behalf Of Terdale,
Shantibhushan
Sent: Tuesday, August 26, 2008 12:16 PM
To: boost-users@lists.boost.org
Subject: [Boost-users] base64_from_binary Q
I am using this sample to prove myself that base64_from_binary and
binary_from_base64 can be used in my app. But I am having little problem
and not able to understand whats missing
Here is the sample
#include "boost/archive/iterators/base64_from_binary.hpp"
#include "boost/archive/iterators/binary_from_base64.hpp"
#include "boost/archive/iterators/transform_width.hpp"
#include <string>
#include <iostream>
using namespace std;
using namespace boost::archive::iterators;
typedef
base64_from_binary<
transform_width
base64_t;
typedef transform_width< binary_from_base64std::string::iterator, sizeof(char) * 8, 6
binary_t;
int main() { string str = "Hello, world!"; cout << str << endl; string enc(base64_t(str.begin()), base64_t(str.end())); // Problem here. It works when I specify "str.end()-1" instead of "str.end()" but I loose last character after decoding. cout << enc << endl; string dec(binary_t(enc.begin()), binary_t(enc.end())); cout << dec << endl; return 0; } Will appreciate any help. I tried std::copy as well and have same problem.
Any existing documentation will be found in the serialization library under Dataflow iterators.
This problem has been reported. I haven't found the time to investigate the best way to fix it.
Note that there are tests in the serialization library for this facility and all the dataflow iterators.
Investigating these might shed some light on things.
RObert Ramey
"Terdale, Shantibhushan"
base64_t;
typedef transform_width< binary_from_base64std::string::iterator, sizeof(char) * 8, 6
binary_t;
int main() { string str = "Hello, world!"; cout << str << endl; string enc(base64_t(str.begin()), base64_t(str.end())); // Problem here. It works when I specify "str.end()-1" instead of "str.end()" but I loose last character after decoding. cout << enc << endl; string dec(binary_t(enc.begin()), binary_t(enc.end())); cout << dec << endl; return 0; } Will appreciate any help. I tried std::copy as well and have same problem. ------------------------------------------------------------------------------ _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Hi,
Well I ran into this issue too. This is the way how I've solved this:
template<typename InputContainerType>
inline String base64_encode(InputContainerType const & cont)
{
using namespace boost::archive::iterators;
typedef base64_from_binary<
transform_width<
typename InputContainerType::const_pointer, 6, 8, boost::uint8_t
>
> base64_t;
return String(base64_t(&cont[0]), base64_t(&cont[0] + cont.size()));
}
template
I am using this sample to prove myself that base64_from_binary and binary_from_base64 can be used in my app. But I am having little problem and not able to understand whats missing
Here is the sample
#include "boost/archive/iterators/base64_from_binary.hpp"
#include "boost/archive/iterators/binary_from_base64.hpp"
#include "boost/archive/iterators/transform_width.hpp"
#include <string>
#include <iostream>
using namespace std;
using namespace boost::archive::iterators;
typedef
base64_from_binary<
transform_width
base64_t;
typedef
transform_width<
binary_from_base64std::string::iterator, sizeof(char) * 8, 6
binary_t;
int main()
{
string str = "Hello, world!";
cout << str << endl;
string enc(base64_t(str.begin()), base64_t(str.end())); *// Problem here. It works when I specify "str.end()-1" instead of "str.end()" but I loose last character after decoding.*
cout << enc << endl;
string dec(binary_t(enc.begin()), binary_t(enc.end()));
cout << dec << endl;
return 0;
}
Will appreciate any help. I tried std::copy as well and have same problem.
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
Cool. It worked for me too. I tried with different length strings and no
issues.
What do you think could be possible bugs? I see Robert also trying to do
something like this in "basic_text_oprimitive" for the generated string
instead of padding original string.
-----Original Message-----
From: boost-users-bounces@lists.boost.org
[mailto:boost-users-bounces@lists.boost.org] On Behalf Of Vinzenz
Feenstra
Sent: Wednesday, August 27, 2008 2:26 AM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] base64_from_binary Q
Hi,
Well I ran into this issue too. This is the way how I've solved this:
template<typename InputContainerType>
inline String base64_encode(InputContainerType const & cont)
{
using namespace boost::archive::iterators;
typedef base64_from_binary<
transform_width<
typename InputContainerType::const_pointer, 6, 8,
boost::uint8_t
>
> base64_t;
return String(base64_t(&cont[0]), base64_t(&cont[0] +
cont.size()));
}
template
I am using this sample to prove myself that base64_from_binary and binary_from_base64 can be used in my app. But I am having little problem and not able to understand whats missing
Here is the sample
#include "boost/archive/iterators/base64_from_binary.hpp"
#include "boost/archive/iterators/binary_from_base64.hpp"
#include "boost/archive/iterators/transform_width.hpp"
#include <string>
#include <iostream>
using namespace std;
using namespace boost::archive::iterators;
typedef
base64_from_binary<
transform_width
base64_t;
typedef
transform_width<
binary_from_base64std::string::iterator, sizeof(char) * 8, 6
binary_t;
int main()
{
string str = "Hello, world!";
cout << str << endl;
string enc(base64_t(str.begin()), base64_t(str.end())); *// Problem
here. It works when I specify "str.end()-1" instead of "str.end()" but
I loose last character after decoding.*
cout << enc << endl;
string dec(binary_t(enc.begin()), binary_t(enc.end()));
cout << dec << endl;
return 0;
}
Will appreciate any help. I tried std::copy as well and have same problem.
---------------------------------------------------------------------- --
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Eames, Andrew
-
Robert Ramey
-
Terdale, Shantibhushan
-
Vinzenz Feenstra