unicode - (solved) c - get the number of symbols to be printed from a string -


i need find out how many symbols printed string. let's have 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 given white char utf8 representation , returns string of it

only 2 red symbol printed ("漢a").

if run:

strlen(buf); 

i receive length of 9

what need function count number of to printed symbols, is, in case: 2

i need solution without external libraries.

any ideas on matter?

in case still has question:

a solution problem know cursor is. guy here has nice piece of low level code can read cursor position.

this not direct answer question, knowing cursor is, before , after press key, resolved particular problem.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -