c++ - English and Greek UTF characters difference -
i have defined same char array english , greek characters.
char mytext[]="ΗΤΙΑ ΗΤΙΑΑΑ ΛΟΥΛΟΥΔΙΑΣΜΕΝΗ!!!1234567890"; // char mytext[]="htia htiaaa louloudiasmenh!!!1234567890";
when print length strlen(mytext);
of char array first 1 has greek utf8 characters has length of 63 characters second has 39. why happened? can fix or proper question how syntax greek unicode greek character program understand them correctly?
i send char array led matrix , message not display on screen when chars english. seems greek characters or non-ascii characters bigger 1 byte.
i have switch function check characters , returns appropriate byte array each letter.i have set default case of switch character !
instead of getting htia htia
!h!t!i!a!
. switch understands greek character more 1 byte , returns first default case witch !
, correct character.
also when try print text error on serial monitor(the characters not display correctly).
since utf-8 characters can have multiple bytes, , strlen counts number of bytes until first null character, strlen overcount length of utf-8 strings. 1 solution use mbstowcs() convert string wide character string, wcslen() length of wide-character string.
p.s. here demonstration of effect mentioned in question.
Comments
Post a Comment