LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Comparing strings in linux (https://www.linuxquestions.org/questions/linux-software-2/comparing-strings-in-linux-743385/)

raviraj2018 07-28-2009 09:11 AM

Comparing strings in linux
 
Hi,

I am looking for a function which is equivalent to comparestring()(WIN32) function. Problem is the compariosion should be case insensitive and according to the local user settings.

Here is what I came upon till now.

strcoll() function can be used to compare the strings according to the user locale, but it is not case insensitive.

Using GTK I can use

g_utf8_casefold (), to make the two input strings case insensitive.
g_utf8_collate () to compare the strings according to the user locale.

The problem is both the functions require the strings input be UTF-8.

Can any one suggest a correct solution?

catkin 07-28-2009 09:41 AM

strcasecmp

raviraj2018 07-29-2009 12:21 AM

strcasecmp will not satisfy the need as it will compare the strings by converting them to upper/lower case. When using the international text , does it give correct results?

catkin 07-30-2009 03:04 AM

Quote:

Originally Posted by raviraj2018 (Post 3623796)
strcasecmp will not satisfy the need as it will compare the strings by converting them to upper/lower case. When using the international text , does it give correct results?

I don't know; it should conform to locale settings; you could try it.


All times are GMT -5. The time now is 12:44 PM.