wchar_t to char[128]

Discussion in 'C Programming' started by Manoj Jangid, Dec 6, 2007.

  1. Manoj Jangid

    Manoj Jangid Guest

    Hi
    how do i convert wchar_t to char[128] or vice versa

    Kind Regards
     
    Manoj Jangid, Dec 6, 2007
    #1
    1. Advertisements

  2. [c and c++ are not the same langauge; my answer is for c (since you posted
    to clc) so i'm not following your followup-to.]

    in comp.lang.c i read:

    >how do i convert wchar_t to char[128] or vice versa


    a single wide-character can be converted to a multi-byte character sequence
    with the wctomb function.

    if the wchar_t corresponds with a single char then wctob may be used, and
    you may use it to determine if such is the case, though if you are prepared
    for up to MB_CUR_MAX bytes of result you may as well just use wctomb.

    to convert a multi-byte character sequence into a wide-character use mbtowc.
    if you have string of multi-byte characters then look at mbstowcs, which
    produces a wide-character string result.

    each of these may fail so be sure to pay attention to the return value.

    --
    a signature
     
    those who know me have no need of my name, Dec 6, 2007
    #2
    1. Advertisements

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:
    792
  2. wwj
    Replies:
    24
    Views:
    2,914
    Mike Wahler
    Nov 7, 2003
  3. Ben Pfaff
    Replies:
    5
    Views:
    699
    Tristan Miller
    Jan 17, 2004
  4. lovecreatesbeauty
    Replies:
    1
    Views:
    1,408
    Ian Collins
    May 9, 2006
  5. Replies:
    6
    Views:
    469
    Pete Becker
    Sep 11, 2006
  6. Replies:
    9
    Views:
    548
    Siddhartha Gandhi
    Apr 9, 2007
  7. Replies:
    3
    Views:
    1,414
    James Kanze
    Aug 15, 2008
  8. Eric Sosman

    Re: Integer 128 != Integer 128 ??

    Eric Sosman, Oct 12, 2010, in forum: Java
    Replies:
    6
    Views:
    1,201
    Screamin Lord Byron
    Oct 13, 2010
Loading...