I'm building an MFC project in C++. I have a text field, in which the user is expected to type a number. I can convert it to integer when an English keyboard is used. But when the user switches to a Japanese keyboard, it doesn't work.
I know that the Japanese keyboard creates double-byte characters. But I don't know how to convert them to integer.
Sory for lacking of information.
My intention is check whether the input user types in text field is a number or not. But it doesn't recognize the number with Japanese keyboard. I tried some methods, such as: strtol(), _wtoi. But the result (frequency) is always 0; The string I got when debuging is 123456789 instead of 123456789. Here is my code
CString strFrequency;
GetDlgItem(IDC_EDIT_FREQUENCY)->GetWindowText(strFrequency);
if(strFrequency.IsEmpty()){
CDialog::OnOK();
return;
}
for(int i=1; i<strFrequency.GetLength(); i+=2) {
if(!std::isdigit(strFrequency[i])){
MessageBox("数字で入力してください。","発表支援");
return;
}
}
int frequency = atoi(strFrequency);
Can everybody help me?
Thanks in advance