Question: I haven't long time in touch with C language. I have some questions related to chinese words and strncpy. 

```
char* testString = "你好嗎?"
sizeof(testString) => it prints out 4.
strlen(testString) => it prints out 10.

```

When i want to copy to another char array, i have some issue.

char msgArray[7]; /\* This is just an example. Due to some limitation, we have limited the buffer size. \*/

If i want to copy the data, i need to check 

```
if (sizeof(testString) < sizeof(msgArray)) {
    strncopy(msgArray, testString, sizeof(msgArray));
}

```

It will have problem. The result is it will only copy a partial data. 

Actually it should have compared with 

```
if (strlen(testString) < sizeof(msgArray)) {

}
else {
   printf("too long");
}

```

But i don't understand why it happened. 

If i want to define to limit the characters count (including unicode (eg. chinese characters), how can i achieve to define the array? I think i can't use the char[] array. 

Thanks a lot for all the responses.

My workaround solution: I finally decide to cut the strings to meet the limited bytes.

Answer: 
Pointers are not arrays. `testString` is a pointer and therefore, `sizeof(testString)` will give the size of pointer instead of the string it points to. 

`strlen` works differently and only for null terminated `char` arrays and string literals. It gives the length of the string preceding the null character.
normally you can use wchar\_t to represent UTF characters (non-English characters), and each character may need 2 or 4 bytes. And if you really want to count number of characters in a quick way, use uint32\_t(unsigned int) instead of char/wchar\_t because UTF32 is guarantee each character (including non-English character) will have the same size of 4 bytes.

sizeof(testString) will only give you the size of a pointer itself which is 4 in 32bit system and 8 in 64bit system.

use wcslen to get the string len if you're using wchar\_t; if you're using uint32\_t, you need to write your own strlen function similar as follow:

```
size_t strlenU32(const uint32_t *s) {
    const uint32_t *u = s;
    while (*u) u++;
    return u - s;
}

```