LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-10-2016, 09:20 AM   #1
Amu
LQ Newbie
 
Registered: Jul 2016
Posts: 1

Rep: Reputation: Disabled
atoi() does not work to to convert UTF-8 string to integer on Linux


Hello,

I need to read a number from a .txt file which is in UTF-8 format.

In my program I'm reading this number as a string from .txt file.

Then using atoi() to convert it to integer. But for any number atoi() is giving output as 0.

I understand that in Linux default encoding format is UTF-8 and according to information I received from google search atoi() should work in this case.

Is there any way to make this work? or any other way or logic to convert UTF-8 string(which is always going to consist numbers in my case)to integer.
 
Old 07-10-2016, 10:17 AM   #2
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 10,007

Rep: Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192Reputation: 3192
As the function has existed for some time and I doubt it is having issues, perhaps you could provide the code and example that it does not work with to give a clearer picture.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to convert string to integer back to string C++ LazerPhreak Programming 1 03-13-2010 07:32 PM
linux script - convert string to an integer lewinmg Linux - Newbie 6 04-05-2009 05:23 PM
c convert integer to string? kpachopoulos Programming 5 08-23-2006 11:57 AM
How do you convert a string to an integer? wbdune Linux - Newbie 11 11-01-2003 02:01 PM
convert integer to string (atoi?) lea Programming 6 10-11-2002 05:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:36 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration