multibyte length

Discussion in 'C Programming' started by Jordan Abel, Mar 3, 2006.

  1. Jordan Abel

    Jordan Abel Guest

    Is there a function to find the length, in wide characters, of a
    multibyte string?
     
    Jordan Abel, Mar 3, 2006
    #1
    1. Advertising

  2. Jordan Abel

    Micah Cowan Guest

    Jordan Abel <> writes:

    > Is there a function to find the length, in wide characters, of a
    > multibyte string?


    <OT>
    If you have the POSIX version of mbstowcs, you can pass it a NULL
    first argument to get this number.
    </OT>

    If you limit yourself to Standard C, I think you have to actually
    perform the conversion, and then find out with wcslen().
     
    Micah Cowan, Mar 3, 2006
    #2
    1. Advertising

  3. Jordan Abel

    Jordan Abel Guest

    On 2006-03-03, Micah Cowan <> wrote:
    > Jordan Abel <> writes:
    >
    >> Is there a function to find the length, in wide characters, of a
    >> multibyte string?

    >
    > <OT>
    > If you have the POSIX version of mbstowcs, you can pass it a NULL
    > first argument to get this number.


    Given that this came up when i was trying to answer someone's question
    in c.u.p, this is relevant, thanks.

    > </OT>
    >
    > If you limit yourself to Standard C, I think you have to actually
    > perform the conversion, and then find out with wcslen().


    The reason for this was to be able to perform the conversion into memory
    that is from malloc while calling malloc only once. in order to make a
    wide copy of argv to pass to a "wmain"
     
    Jordan Abel, Mar 3, 2006
    #3
  4. Jordan Abel

    Micah Cowan Guest

    Jordan Abel <> writes:

    > On 2006-03-03, Micah Cowan <> wrote:
    > > Jordan Abel <> writes:
    > >
    > >> Is there a function to find the length, in wide characters, of a
    > >> multibyte string?

    > >
    > > <OT>
    > > If you have the POSIX version of mbstowcs, you can pass it a NULL
    > > first argument to get this number.

    >
    > Given that this came up when i was trying to answer someone's question
    > in c.u.p, this is relevant, thanks.
    >
    > > </OT>
    > >
    > > If you limit yourself to Standard C, I think you have to actually
    > > perform the conversion, and then find out with wcslen().

    >
    > The reason for this was to be able to perform the conversion into memory
    > that is from malloc while calling malloc only once. in order to make a
    > wide copy of argv to pass to a "wmain"


    Makes sense to me: snprintf() allows this. It's beyond me why Standard
    C neglected to provide such a thing in the first place. I kind of hope
    that future versions will add the POSIX behavior, as it's very useful,
    and certainly not hard to implement.
     
    Micah Cowan, Mar 3, 2006
    #4
    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. Billow
    Replies:
    2
    Views:
    1,361
    Billow
    Dec 1, 2005
  2. kaith

    java multibyte char array

    kaith, Aug 21, 2003, in forum: Java
    Replies:
    3
    Views:
    3,891
    Jon A. Cruz
    Aug 21, 2003
  3. Zygmunt Krynicki

    Multibyte string length

    Zygmunt Krynicki, Oct 9, 2003, in forum: C Programming
    Replies:
    19
    Views:
    724
    Dan Pop
    Oct 14, 2003
  4. Owner

    How to determine Multibyte string length.

    Owner, Apr 9, 2011, in forum: C Programming
    Replies:
    4
    Views:
    834
    Ben Bacarisse
    Apr 11, 2011
  5. kobayashi
    Replies:
    9
    Views:
    224
    Evan Driscoll
    Nov 26, 2012
Loading...

Share This Page