Thread: Size of a unicode string

  1. #1
    Registered User
    Join Date
    May 2008

    Size of a unicode string


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

    Unicode string is a bin data?


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

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

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

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    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
    Banks of the River Styx
    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
    Join Date
    Oct 2007
    Inside my computer
    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, 01:48 PM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 12:47 PM
  5. Classes inheretance problem...
    By NANO in forum C++ Programming
    Replies: 12
    Last Post: 12-09-2002, 03:23 PM