[prev in list] [next in list] [prev in thread] [next in thread] 

List:       gtkmm
Subject:    Re: convert from alpha to int
From:       mohgtkmm <mohgtkmm () gmail ! com>
Date:       2012-03-20 0:38:04
Message-ID: 4F67D16C.70108 () gmail ! com
[Download RAW message or body]

Hi,
Just a note: These:  (٠١٢٣٤٥٦٧٨٩) are not Arabic, but Hindi. Arabic 
numbers are 1,2,3 .... and the famous zero they invented themselves!  
However, those hindi numbers are used in some arabic countries in the 
middle-east.

On 03/19/2012 10:01 AM, Kjell Ahlstedt wrote:
> Hi,
>
> I don't know of any way that is both good and easy.
> atoi() is easy to use, but not very good. Both atoi("2") and 
> atoi("2Hello") will be returned as 2.
>
> Better, but not as easy is
>
> char* endp = 0;
> long i = strtol(s, &endp, 10);
> if (*endp == '\0')
> // It's a number.
>
> Not even this is perfect. If you want to accept trailing blanks, you 
> have to complicate it further. And I don't know how well it works in a 
> totally international program. E.g. I don't know if it accepts Arabic 
> digits (٠١٢٣٤٥٦٧٨٩).
>
> Kjell
>
> 2012-03-19 08:38, Yann Leydier skrev:
>> Hi,
>>
>> I don't know if Glib has functions to perform such a check, but 
>> standard C does:
>> http://www.cplusplus.com/reference/clibrary/cctype/
>>
>> If you know that the string's digital value cannot be 0, then you can 
>> also check a non-null return to atoi or atol (in cstdlib).
>>
>> yann
>>
>> On 18/03/12 20:49, Arbol One wrote:
>>> Thank you for your prompt response.
>>>
>>> I am sorry, I don't think I explained myself well enough. If the user
>>> enters the number 24 in an Gtk::Entry, how can I check if the entry is
>>> actually a number and not a character string?
>>>
>>> thank in advance
>>>
>>> *From:*Kjell Ahlstedt [mailto:kjell.ahlstedt@bredband.net]
>>> *Sent:* Thursday, March 15, 2012 11:12 AM
>>> *To:* Arbol One
>>> *Cc:* gtkmm-list@gnome.org
>>> *Subject:* Re: convert from alpha to int
>>>
>>> 2012-03-15 13:53, Arbol One skrev:
>>>
>>> Does Glibmm provide a way to convert an character value to an 
>>> integer value?
>>>
>>> TIA
>
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list@gnome.org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list

_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
http://mail.gnome.org/mailman/listinfo/gtkmm-list

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic