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: 
What do you mean by "characters"?

`std::basic_string` is just a container for a series of values, that we think of as a string. It doesn't care what *encoding* the values are in; all it does is store and manage an ordered sequence of values. Therefore it's `size` and `length` functions state how many values it stores.

If your `std::wstring` contains a string that represents, say, a valid UTF-16-encoded string, `std::wstring` does not care. Unicode encodings are just ways to encode codepoints. UTF-16 uses 16-bit code units to encode its codepoints, which can include surrogate pairs of 16-bit values that correspond to a single Unicode codepoint.

However, a Unicode codepoint is not a "character" by some definitions of that term. For example, there are combining codepoints, where multiple codepoints are combined to form a grapheme. There are non-visible codepoints (control codes and such).

If you want to know how many codepoints are in a `std::wstring`, then you will have to walk that string with a function that can process UTF-16 data. If you want to know how many *graphemes* (logical glyphs) are in the string, then you will need to walk it with a much more complex algorithm.
Are you looking for wcslen?

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

```