LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
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, 10: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, 10: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,563
Blog Entries: 29

Rep: Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179Reputation: 1179
strcasecmp
 
Old 07-29-2009, 01: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, 04: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,563
Blog Entries: 29

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


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


All times are GMT -5. The time now is 03:04 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration