Size of a unicode string

This is a discussion on Size of a unicode string within the C Programming forums, part of the General Programming Boards category; Hello Someone know how i can find out the size of a unicode string? Unicode string is a bin data? ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    39

    Size of a unicode string

    Hello

    Someone know how i can find out the size of a unicode string?

    Unicode string is a bin data?

    Thanks

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    There should be always be a strlen() type of function for your unicode strings.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    39
    strlen() is just for ANSI caracters


    I need something that give me the size of some unicode string
    Thanks

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    If you're using standard wchar's, then strlen() is called wcslen(). If you're using other kinds of wide characters, then that library/header will define a strlen-type function called ... something. Presumably you know what library/header you're using.

  5. #5
    int x = *((int *) NULL); Cactus_Hugger's Avatar
    Join Date
    Jul 2003
    Location
    Banks of the River Styx
    Posts
    902
    What you use depends on what your string is encoded as. What encoding are you using? ("Unicode" is not a valid answer.)

    For UTF-8 string that are nul terminated, strlen() will return the length, in bytes, of that string.
    (On Windows, you're likely dealing with UTF-16, if you're using Unicode, and tabstop's method should work.)
    long time; /* know C? */
    Unprecedented performance: Nothing ever ran this slow before.
    Any sufficiently advanced bug is indistinguishable from a feature.
    Real Programmers confuse Halloween and Christmas, because dec 25 == oct 31.
    The best way to accelerate an IBM is at 9.8 m/s/s.
    recursion (re - cur' - zhun) n. 1. (see recursion)

  6. #6
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,556
    Quote Originally Posted by Cactus_Hugger View Post
    For UTF-8 string that are nul terminated, strlen() will return the length, in bytes, of that string.
    Perhaps. But perhaps not.
    UTF-8 is very much variable length and as such, it can return incorrect length because some characters span several bytes. Unicode is a tricky topic.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  2. Replies: 16
    Last Post: 11-23-2007, 12:48 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 04:45 PM
  4. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 11:47 AM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 02:23 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21