Hi all,
Is there a portable way of transforming a wchar_t to a char and/or
wstring to a string.
Are there any gurantees for the layout of a wchar_t, like every other
byte is a char?
I am not worried about data loss.
Also is the output of this program guranteed to work as I expect. Its
seems fine on g++ but C++ Builder 6 does not output anything to wcout.
Is this a compiler issue?
This is what I expect:-
And the bit in brackets [have been sent to wcout] instead of cout
And the bit in brackets [have been sent to wcout] instead of cout
And the bit in brackets [have been sent to wcout] instead of cout
and C++ Builder give me:-
And the bit in brackets [] instead of cout
And the bit in brackets [] instead of cout
And the bit in brackets [] instead of cout
#include <iostream>
int main()
{
wchar_t *wptr=L"has been sent to wcout";
std::wstring wstr(wptr);
std::cout << "And the bit in brackets [";
std::wcout << wptr;
std::cout << "] instead of cout" << std::endl;
std::cout << "And the bit in brackets [";
std::wcout << wstr;
std::cout << "] instead of cout" << std::endl;
std::cout << "And the bit in brackets [";
std::wcout << wstr.c_str();
std::cout << "] instead of cout" << std::endl;
return 0;
}
--
Adrian Cornish
BlueDreamer Ltd
Phone: 0208 506 1226
Mobile: 07968 062 926
Website: www.bluedreamer.com