G
gerg
How would one convert a wstring to a string?
This is what I have so far:
bool copyto(std::string& l,std::wstring& r)
{
bool ret = false;
size_t i = 0;
const size_t n = r.length()+1;
l.resize(n); // make sure we have enough
for(;i<n;++i)
{
l = r;
}
l = 0;
l.resize(n-1);
return ret;
}
which I know is pretty gruesome, but does the job.
the reason for: const size_t n = r.length()+1;
is because I want to make sure I have enough room to transfer the
characters.
This is what I have so far:
bool copyto(std::string& l,std::wstring& r)
{
bool ret = false;
size_t i = 0;
const size_t n = r.length()+1;
l.resize(n); // make sure we have enough
for(;i<n;++i)
{
l = r;
}
l = 0;
l.resize(n-1);
return ret;
}
which I know is pretty gruesome, but does the job.
the reason for: const size_t n = r.length()+1;
is because I want to make sure I have enough room to transfer the
characters.