LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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
  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: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
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



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
Comparing binaries - excluding __DATE__ and __TIME__ strings bcg121 Linux - Software 2 12-16-2019 06:48 PM
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 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

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:00 AM.

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