Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Re: Multi width char initialization - I'll just always use wchar_t

Reply
Thread Tools

Re: Multi width char initialization - I'll just always use wchar_t

 
 
Jim Langston
Guest
Posts: n/a
 
      10-22-2010

"Jim Langston" <(E-Mail Removed)> wrote in message
news:i9r7kq$hqr$(E-Mail Removed)...
> This snippet will not compile:
>
> typedef char char_type;
> std::basic_string<char_type> output( L"Syntax error." );
>
> The reason being std::basic_string<char> can be constructed from a char*
> but not a wchar_t*. If I change it from L"Syntax error." to "Syntax
> error." then it won't compile when char_type is wchar_t. I intend on
> supporting up to u32 or higher so this is a quandry.
>
> I tried:
> #define CTP_ L
> std::basic_string<char_type> output( CTP_"Syntax error." );
> but got:
> error C2065: 'L' : undeclared identifier
>
> and I'd rather use templates if possible than defines. Any ideas?


Thinking about it, I'll just use wchar_t should support every character
currently used so I can just use it.

 
Reply With Quote
 
 
 
 
Geoff
Guest
Posts: n/a
 
      10-22-2010
On Fri, 22 Oct 2010 11:07:24 -0700, "Jim Langston"
<(E-Mail Removed)> wrote:

>
>"Jim Langston" <(E-Mail Removed)> wrote in message
>news:i9r7kq$hqr$(E-Mail Removed)...
>> This snippet will not compile:
>>
>> typedef char char_type;
>> std::basic_string<char_type> output( L"Syntax error." );
>>
>> The reason being std::basic_string<char> can be constructed from a char*
>> but not a wchar_t*. If I change it from L"Syntax error." to "Syntax
>> error." then it won't compile when char_type is wchar_t. I intend on
>> supporting up to u32 or higher so this is a quandry.
>>
>> I tried:
>> #define CTP_ L
>> std::basic_string<char_type> output( CTP_"Syntax error." );
>> but got:
>> error C2065: 'L' : undeclared identifier
>>
>> and I'd rather use templates if possible than defines. Any ideas?

>
>Thinking about it, I'll just use wchar_t should support every character
>currently used so I can just use it.


To quote Dr. Joseph M. Newcomer [MVP] from microsoft.public.vc.mfc
fame: "Forget char exists."
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
converting from windows wchar_t to linux wchar_t yakir22@gmail.com C++ 3 08-15-2008 09:04 AM
(const char *cp) and (char *p) are consistent type, (const char **cpp) and (char **pp) are not consistent lovecreatesbeauty C Programming 1 05-09-2006 08:01 AM
/usr/bin/ld: ../../dist/lib/libjsdombase_s.a(BlockGrouper.o)(.text+0x98): unresolvable relocation against symbol `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostre silverburgh.meryl@gmail.com C++ 3 03-09-2006 12:14 AM
Textbox width scaling to width of data not width of page? AndrewF ASP .Net 1 10-10-2005 04:38 PM
Trying to create a CSS box that is always is always the width of an image placed inside it (and no wider) Deryck HTML 4 06-22-2004 08:25 PM



Advertisments