- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- std::wcout not working
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2006 05:38 AM
тАО08-24-2006 05:38 AM
std::wcout not working
Host: HP-UX artemis B.11.11 U 9000/800 2599003817
Compiler: aCC: HP ANSI C++ B3910B A.03.73
locale: zh_CN.utf8
Wide character string containing UTF-16 characters does not display on std::wcout but works fine when I use printf with %S.
#include
#include
int main()
{
setlocale(LC_ALL,"");
wchar_t real[25] = {0};
// Original UTF-16 used for checking.
real[0] = 0x003C;
real[1] = 0x65F6;
real[2] = 0x95F4;
real[3] = 0xFF08;
real[4] = 0x7992;
real[5] = 0xFF09;
real[6] = 0x003E;
real[7] = 0x005D;
real[8] = 0x0000;
char src[25] = {0};
// UTF-8 to mach expected output for UTF8 local
src[0] = 0x3c; // 0x003c
src[1] = 0xE6; // 0x65F6
src[2] = 0x97;
src[3] = 0xB6;
src[4] = 0xE9; // 0x95F4
src[5] = 0x97;
src[6] = 0xB4;
src[7] = 0xEF; // 0xFF08
src[8] = 0xBC;
src[9] = 0x88;
src[10] = 0xE7; // 0x7992
src[11] = 0xA6;
src[12] = 0x92;
src[13] = 0xEF; // 0xFF09
src[14] = 0xBC;
src[15] = 0x89;
src[16] = 0x3E; // 0x003E
src[17] = 0x5D; // 0x005D
src[18] = 0x0;
// Using printf
printf("s:%s\n",src);
printf("S:%S\n",real);
// Output the UTF-8
std::cout << "N:" << src << std::endl;
// Output the UTF-16
std::wcout << "W:" << real << std::endl;
return(0);
}
ash-3.00# aCC -AA unicodetest.cpp
- Tags:
- wchar_t
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-24-2006 05:55 AM
тАО08-24-2006 05:55 AM
Re: std::wcout not working
Note that the last line contains no visable characters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-25-2006 02:12 PM
тАО08-25-2006 02:12 PM
Re: std::wcout not working
Please contact the Response Center and file a bug report.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2006 03:54 AM
тАО08-28-2006 03:54 AM
Re: std::wcout not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2006 12:59 PM
тАО08-28-2006 12:59 PM
Re: std::wcout not working
You need a support contract. Is there anyone in your company that knows about that?
If you have it, there should be links off of the main ITRC page: "remote support and diagnostics"
This page may have some info?
http://welcome.hp.com/country/us/en/contact_us.html
Our contact from RW says there are several issues:
std::wcout has unspecified behavior. There's no requirement that
it use codecvt or even what kind of streambuf it should use
And:
The behavior of codecvt
So I suppose you should continue to use stdio or call wcstombs if you have some wchar_t strings and want to use cout.
- Tags:
- wcstombs
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-28-2006 01:31 PM - edited тАО10-30-2011 08:03 PM
тАО08-28-2006 01:31 PM - edited тАО10-30-2011 08:03 PM
Re: std::wcout not working
>Our contact from RW says there are several issues:
Oops, I forgot to mention his solution using imbue:
typedef std::codecvt_byname ucs2utf;
std::wcout.imbue(std::locale(std::locale(), new ucs2utf("zh_CN.utf8")));
- Tags:
- imbue
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-29-2006 05:50 AM
тАО08-29-2006 05:50 AM
Re: std::wcout not working
std::wcout.imbue(std::locale("zh_CN.utf8"));
This way you'll get consistent behavior across all locale categories, including numeric.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-29-2006 02:40 PM
тАО08-29-2006 02:40 PM