string class that can convert between wchar_t and char

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Bren

    string class that can convert between wchar_t and char


    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! =-----
  • Default User

    #2
    Re: string class that can convert between wchar_t and char

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


    What is the nature of the conversion?



    Brian Rodenborn

    Comment

    • Thomas Wintschel

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

      "Bren" <iambrenNOSPAM@ sympatico.ca> wrote in message
      news:uqornv4v7b 4hvf1a6mmm2qq9r js56166s3@4ax.c om...[color=blue]
      >
      > 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?
      >[/color]

      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


      Comment

      • Bren

        #4
        Re: string class that can convert between wchar_t and char

        On Fri, 3 Oct 2003 22:12:52 GMT, Default User <first.last@com pany.com>
        wrote:
        [color=blue]
        >Bren wrote:[color=green]
        >>
        >> Hi all,
        >>
        >> I wonder if anyone knows of a string class out there that can do on
        >> demand conversion from wchar_t to char?[/color]
        >
        >
        >What is the nature of the conversion?[/color]

        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! =-----

        Comment

        • Peter van Merkerk

          #5
          Re: string class that can convert between wchar_t and char

          > >> I wonder if anyone knows of a string class out there that can do on[color=blue][color=green][color=darkred]
          > >> demand conversion from wchar_t to char?[/color]
          > >
          > >What is the nature of the conversion?[/color]
          >
          > Ummmmm, convert a string from wchar_t to char, and/or back?[/color]

          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.merke rk(at)dse.nl


          Comment

          Working...