LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 07-28-2009, 09:11 AM   #1
raviraj2018
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Rep: Reputation: 0
Smile 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?
 
Old 07-28-2009, 09:41 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,512
Blog Entries: 27

Rep: Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174
strcasecmp
 
Old 07-29-2009, 12:21 AM   #3
raviraj2018
LQ Newbie
 
Registered: Jul 2009
Posts: 2

Original Poster
Rep: Reputation: 0
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?
 
Old 07-30-2009, 03:04 AM   #4
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,512
Blog Entries: 27

Rep: Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174Reputation: 1174
Quote:
Originally Posted by raviraj2018 View Post
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.
 
  


Reply

Tags
linux, string


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with comparing strings in php Yoyo302 Programming 5 06-30-2009 04:16 AM
c++ - if/else problem comparing strings babag Programming 14 05-19-2008 11:32 PM
Comparing binaries - excluding __DATE__ and __TIME__ strings bcg121 Linux - Software 1 11-30-2007 03:23 PM
comparing 2 strings in shell script dhanabalanb Programming 3 08-01-2007 01:17 PM
Error comparing strings and acting on the comparison WindowsBurner Programming 4 10-21-2004 12:37 PM


All times are GMT -5. The time now is 05:54 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration