string class that can convert between wchar_t and char

Discussion in 'C++' started by Bren, Oct 3, 2003.

  1. Bren

    Bren Guest

    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! =-----
     
    Bren, Oct 3, 2003
    #1
    1. Advertising

  2. Bren

    Default User Guest

    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
     
    Default User, Oct 3, 2003
    #2
    1. Advertising

  3. [OT] Re: string class that can convert between wchar_t and char

    "Bren" <> wrote in message
    news:...
    >
    > 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
     
    Thomas Wintschel, Oct 4, 2003
    #3
  4. Bren

    Bren Guest

    On Fri, 3 Oct 2003 22:12:52 GMT, Default User <>
    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! =-----
     
    Bren, Oct 6, 2003
    #4
  5. > >> 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
     
    Peter van Merkerk, Oct 7, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wwj
    Replies:
    7
    Views:
    587
  2. wwj
    Replies:
    24
    Views:
    2,557
    Mike Wahler
    Nov 7, 2003
  3. lovecreatesbeauty
    Replies:
    1
    Views:
    1,121
    Ian Collins
    May 9, 2006
  4. Replies:
    4
    Views:
    3,315
  5. Replies:
    3
    Views:
    1,149
    James Kanze
    Aug 15, 2008
Loading...

Share This Page