1

I realize there may be similar questions, but I have been really stuck for a while now. I'm operating on Windows 10 using C++ and the Win32 API.

I need to read a user textbox for a hexadecimal code, something like Ѱ or U+0470, although the 'U+' is not going to be present. After receiving this value, I need to take the code and print the appropriate symbol.

Using the code below I can print any Unicode symbol:

createWindow(L"Static", L"\u2230", WS_VISIBLE | WS_CHILD, 10,10, 190,40, hWnd, NULL,NULL,NULL);

I can also read the textbox using GetWindowText(). However, I can not figure out how to get the user's input 0470 and print this as a Unicode character in the textbox.

2
  • I can not figure out how to the user's input 0470 Which api are you going to use to accept user input? Commented Oct 6, 2020 at 9:39
  • For the record and clarification, I'm using the win32api and I am already familiar with printing basic text. I just needed a way to convert the hexadecimal to the appropriate Unicode and format for printing. Commented Oct 6, 2020 at 10:44

1 Answer 1

0

You'll need to convert the string L"0470" into a number. It's a base-16 number, so you'd use std::wcstoul from <cwchar>. You can then cast this number to a WCHAR. I assume you know how to turn a single character into a string.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you so much! It turns out wcstoul is exactly what I was missing.
Well it sounds like you should accept the answer then ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.