I need to find out how many symbols are to be printed from a string. Let's say I have this code:
char buf[200];
strcpy(buf, "\033[31m"); //Red color control sequence
strcat(buf, to_utf8(L'漢'));
strcat(buf, "a");
printf("%s", buf);
where
to_utf8(wchar_t c);
transforms the given white char into its utf8 representation and returns a string of it
Only 2 red symbol will be printed ("漢a").
If I were to run:
strlen(buf);
I would receive a length of 9
What I need is a function which will count the number of to be printed symbols, that is, in this case: 2
I need a solution without any external libraries.
Any ideas on this matter?