From CString to int with Unicode

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?
 
A

Alex Blekhman

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.
 
B

Burt Johnson

Thanks everyone for your suggestions! Problem is now solved, and I am on
to bigger and (hopefully) better things. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top