From CString to int with Unicode

  • Thread starter Thread starter Burt Johnson
  • Start date Start date
B

Burt Johnson

I have a CString with a numeric string in it. In the past, I would use
atoi( ) to convert to an int. That doesn't work with Unicode though.

What is the proper Unicode method for converting a CString to an
integer?
 
Burt said:
I have a CString with a numeric string in it. In the
past, I would use atoi( ) to convert to an int. That
doesn't work with Unicode though.

What is the proper Unicode method for converting a
CString to an integer?

Proper method is _ttoi/_ttol. CString is a class that
contains generic characters: TCHAR's. So, when working with
it you need to use generic routines.

If you're using MSVC7[.1], then there is CStringT class now.
It has CString generic specialization; and CStringA and
CStringW for ANSI and Unicode, respectively.
 
Thanks everyone for your suggestions! Problem is now solved, and I am on
to bigger and (hopefully) better things. :-)
 
Back
Top