Question: I am working with std::wstring variables (C++ Language) & I am trying to determine the length(in characters) of the string.

The functions .length & .size() give results that aren't the length in characters(I think they tell me how many wide chars there are?).

**So is there a way to determine the length in characters of a wstring?**

Answer: 
Depending on where your string comes from, you may not have *any* control over what it *means*, i.e. how it is encoded. To turn your string into something definite semantics, you may have to perform the following steps:

1. Read byte string from the environment via `argv` or `getenv`. This is a byte string with platform and locale-dependent encoding.
2. Turn the byte string into an internal, fixed width (there are caveats) wide string by means of `mbstowcs()`. *You still don't know the encoding of the result!* All you know is that each wide character is big enough to hold any of the "platform's character values", whatever that means. (In Windows, it means something [broken](https://softwareengineering.stackexchange.com/questions/102205/should-utf-16-be-considered-harmful)).
3. Obtain a sequence of Unicode code points (i.e. definitive data that you can manipulate codepoint-wise) by using ICU or `iconv()` to translate WCHAR into UCS-4/UTF-32. Now you know what you're dealing with!

If you are reading data from a file with a documented encoding, or from the network, you would instead convert from the documented file encoding to UCS-4.

Once you have obtained a sequence of code points, the low-level language support for text processing ends. A sequence of code points is the best you can get at the binary level to represent a text. Any higher-level textual manipulation and processing is complicated and subtle and depends deeply on a proper definition of "text", so this is best left to a dedicated Unicode library (such as ICU). At the programming language level, "characters" are code points, but in any serious application that's probably not what you want and you want to know about graphemes and normalization and a hundred other little things.
Are you looking for wcslen?

```
#include <wchar.h>
size_t wcslen(const wchar_t *s);

```