Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > string class that can convert between wchar_t and char

Reply
Thread Tools

string class that can convert between wchar_t and char

 
 
Bren
Guest
Posts: n/a
 
      10-03-2003

Hi all,

I wonder if anyone knows of a string class out there that can do on
demand conversion from wchar_t to char?

We are writing an app that will need to be localized and cross
platform. At this point we are going with Unicode and wchar_t arrays.
I am considering using the string class.

We also use a lot of third party libraries, most of which prefer
ordinary char arrays.

I am hoping to find a class or macro that can do in-place conversion
of wchar_t to char arrays, ideally something similar to the MS W2A/A2W
macros. A string class that could accept/manage a wchar_t string and
return a char* with a call similar to c_str() would also be great as
well.

We are currently using a function which accepts a char* to an
allocated string and converts a wchar_t string into it, but this
requires code before (to alloc) and after (to free) every call. I'm
hoping for something a little easier to use.

Any suggestions?



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
 
 
 
Default User
Guest
Posts: n/a
 
      10-03-2003
Bren wrote:
>
> Hi all,
>
> I wonder if anyone knows of a string class out there that can do on
> demand conversion from wchar_t to char?



What is the nature of the conversion?



Brian Rodenborn
 
Reply With Quote
 
 
 
 
Thomas Wintschel
Guest
Posts: n/a
 
      10-04-2003
"Bren" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> Hi all,
>
> I wonder if anyone knows of a string class out there that can do on
> demand conversion from wchar_t to char?
>
> We are writing an app that will need to be localized and cross
> platform. At this point we are going with Unicode and wchar_t arrays.
> I am considering using the string class.
>
> We also use a lot of third party libraries, most of which prefer
> ordinary char arrays.
>
> I am hoping to find a class or macro that can do in-place conversion
> of wchar_t to char arrays, ideally something similar to the MS W2A/A2W
> macros. A string class that could accept/manage a wchar_t string and
> return a char* with a call similar to c_str() would also be great as
> well.
>
> We are currently using a function which accepts a char* to an
> allocated string and converts a wchar_t string into it, but this
> requires code before (to alloc) and after (to free) every call. I'm
> hoping for something a little easier to use.
>
> Any suggestions?
>


This is off-topic and should be asked in a windows newsgroup but...

Try _bstr_t in the ATL package (include comutil.h (or comdef.h)).

Tom


 
Reply With Quote
 
Bren
Guest
Posts: n/a
 
      10-06-2003
On Fri, 3 Oct 2003 22:12:52 GMT, Default User <(E-Mail Removed)>
wrote:

>Bren wrote:
>>
>> Hi all,
>>
>> I wonder if anyone knows of a string class out there that can do on
>> demand conversion from wchar_t to char?

>
>
>What is the nature of the conversion?


Ummmmm, convert a string from wchar_t to char, and/or back?



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 100,000 Newsgroups - 19 Different Servers! =-----
 
Reply With Quote
 
Peter van Merkerk
Guest
Posts: n/a
 
      10-07-2003
> >> I wonder if anyone knows of a string class out there that can do on
> >> demand conversion from wchar_t to char?

> >
> >What is the nature of the conversion?

>
> Ummmmm, convert a string from wchar_t to char, and/or back?


Not every possible wchar_t value can be represented by a char, hence
some conversion needs to take place. Depending on your requirements the
wchar_t to char conversion could be as simple as stripping the higher
order bits or as complicated as converting to an encoding that uses
escape codes to represent certain characters.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl


 
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
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
converting from windows wchar_t to linux wchar_t yakir22@gmail.com C++ 3 08-15-2008 09:04 AM
A simple question - how to convert from UTF8 to wide char (wchar_t) on linux uday.sen@gmail.com C Programming 4 06-06-2006 12:07 PM
(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



Advertisments