Non display characters for selection count
-
Hi I have 3 rows of text in my rich edit. At the end of each line I move a carriage return line feed, to force a new line /r/n. Do these 2 bytes count as 2 characters when determining the count for the selection Thanks
EM_GETSELTEXT is explicit
This message returns the number of characters copied, not including the terminating null character.
The call is terminated by the null character and if you have CR,LF they will count as characters The return is a CHARACTER COUNT, if your edit box is unicode mode it still reflects the character NOT THE NUMBER OF BYTES. Hence when providing a buffer you are best to use an array of TCHAR rather than a standard byte array to allow for size difference. Also note when size a TCHAR array use _countof DO NOT use sizeof for the same reason. Standard unicode aware coding practice. Several of the comments have confusion between CHARACTER and BYTE within the meaning of the windows API. No such confusion exists.
In vino veritas