Search code examples
c++visual-c++mfcwindowsunicode-string

simple sum of Unicode symbol codes


I want to do this:

1) Click event of Convert ! button

User must type 2 value into writable edit controls. After pressing Convert ! program must set sum of these characters Unicode values to first read-only edit control (it's near of " = " symbol). For example, if I set first edit control value as є (which its UTF-16 (hex) encoding value is 0x0404 (0404). It's also known as Cyrillic Capital Letter Ukrainian IE) and second edit control value as @ (which its UTF-16 (hex) encoding value is 0x0040 (0040). It's also known as Commercial At), then result must be a symbol: ф (its UTF-16 encoding value is 0x0444 (0444)). Therefore, its value equals to sum of other edit controls UTF-16 encoding values. How can I do this?

2) Click event of Undo button

By clicking Undo button, it must sets the value of edit control the below this button. This value should be є symbol (as you see its Unicode encoding value is extraction of sum and second edit control's value. How can I do this?

I've searched out for these problem for 2 weeks in Google, MSDN and some different forums. But I couldn't find any helpful topic. I could find only the MultiByteCharacterSet, _mbclen, mblen and _mblen_l functions. If these functions are useful for me, how can I use it/them in my program? Please, give me advice. I'm new to VC++.

Edit

User must enter a character. It is maybe a digit or letter. Not a word or sequence of characters or number.

Thanks for any attention.

P.S: If there are too many and poor mistakes in my grammar, and if the question is duplicate so sorry...

Best regards, Mirjalal.

enter image description here


Solution

  • The input value is already equal to its unicode-16 value. No conversion is needed.

    CString in1(L'1');
    CString in2(L'2');
    CString sum(wchar_t(in1[0] + in2[0]));