home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,665 of 33,346   
   Ulrich Eckhardt to All   
   Re: Are there any ideas out there for ch   
   21 Nov 12 15:35:46   
   
   From: ulrich.eckhardt@dominolaser.com   
      
   Am 16.11.2012 09:55, schrieb Martin Ba:   
   > I remember reading a statement that I found to make sense that was along   
   > the lines of:   
   >   
   > Quote Unknown:   
   >> ... cout and wcout don't make sense. You should   
   >> have one (output) stream and just be able to   
   >> pass it both narrow and wide (strings) like:   
   >>   
   >>     wstring aWcharString( ... );   
   >>     string aCharString( ... );   
   >>     char16_t const* aUTF16String = u"...";   
   >>     unified_out << aWcharString << aCharString << aUTF16String;   
   >>   
   >   
   > So, is there any library out there that does this? Does anyone use this?   
   > Would it make sense to just define overloaded output operators so that   
   > cout would also accept wide strings?   
      
   You can write strings of type char, unsigned char and signed char to   
   wide-character streams. That said, I don't know if you can write   
   std::string to wide-character streams, but I wouldn't mind adding an   
   overload.   
      
   The problem is that sometimes, std::string actually contains UTF-8,   
   while in other cases it contains ASCII or various codepages. Since the   
   string doesn't know its encoding (neither the type nor the actual   
   content define it), it requires guessing. While wchar_t isn't off much   
   better, there are effectively only two encodings for it, UTF-16 and   
   UTF-32, that are easily distinguished via the target platform at compile   
   time.   
      
   Uli   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca