Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / June 2005

Tip: Looking for answers? Try searching our database.

From CString to int with Unicode

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Burt Johnson - 11 Jun 2005 23:43 GMT
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?

Signature

- Burt Johnson
 MindStorm, Inc.
 http://www.mindstorm-inc.com/software.html

Guido Stercken-Sorrenti [MVP VC++] - 11 Jun 2005 23:50 GMT
> What is the proper Unicode method for converting a CString to an
> integer?

wcstol(), for example...
Signature

Guido Stercken-Sorrenti
MVP - Visual Developer / Visual C++

Burt Johnson - 12 Jun 2005 01:22 GMT
Guido Stercken-Sorrenti [MVP VC++] <mspbn@stercken-sorrenti.nospam.com>
wrote:

> > What is the proper Unicode method for converting a CString to an
> > integer?
>
> wcstol(), for example...

Thanks!

Signature

- Burt Johnson
 MindStorm, Inc.
 http://www.mindstorm-inc.com/software.html

Alex Blekhman - 12 Jun 2005 08:48 GMT
> 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.
Burt Johnson - 13 Jun 2005 10:05 GMT
Thanks everyone for your suggestions! Problem is now solved, and I am on
to bigger and (hopefully) better things. :-)

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

Signature

- Burt Johnson
 MindStorm, Inc.
 http://www.mindstorm-inc.com/software.html


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.