473,414 Members | 1,623 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Collating multi-byte strings

Assuming my locale has enough info about codepage and multi-byte
charecters, how should I compare (collate) multi-byte strings (strings
of multi-byte charecters with zero-byte at the end) in ISO C99?

Thanks in advance
Vir

Nov 14 '05 #1
2 2173
In <bv***********@av9195.comtv.ru> Victor Nazarov <vv*****@mail.ru> writes:
Assuming my locale has enough info about codepage and multi-byte
charecters, how should I compare (collate) multi-byte strings (strings
of multi-byte charecters with zero-byte at the end) in ISO C99?


strcoll(), being declared in <string.h>, doesn't seem to be appropriate
for what you want. But I could be wrong on that, the standard being less
than clear on the issue.

In the absence of a mbscoll() function, it seems that your only
alternative is to use mbstowcs() to convert your strings to wide
character strings and then use wcscoll() to compare them.

Dan
--
Dan Pop
DESY Zeuthen, RZ group
Email: Da*****@ifh.de
Nov 14 '05 #2
Dan Pop ÐÉÛÅÔ:
In <bv***********@av9195.comtv.ru> Victor Nazarov <vv*****@mail.ru> writes:

Assuming my locale has enough info about codepage and multi-byte
charecters, how should I compare (collate) multi-byte strings (strings
of multi-byte charecters with zero-byte at the end) in ISO C99?

strcoll(), being declared in <string.h>, doesn't seem to be appropriate
for what you want. But I could be wrong on that, the standard being less
than clear on the issue.

In the absence of a mbscoll() function, it seems that your only
alternative is to use mbstowcs() to convert your strings to wide
character strings and then use wcscoll() to compare them.

Dan


what about:
#include <stdlib.h>
#include <wchar.h>

int my_mbscoll (const char *s, const char *t)
{
wchar_t ws[2], wt[2];
int res;

do {
s += mbtowc (&ws[0], s, MB_CUR_MAX);
t += mbtowc (&wt[0], t, MB_CUR_MAX);
ws[1] = wt[1] = 0;
res = wcscoll (ws, wt);
} while (ws[0] && res == 0);
return res;
}
Nov 14 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: * ProteanThread * | last post by:
but depends upon the clique: ...
1
by: Yaro | last post by:
Hi We want to create case-insensitive database (DB2 8.2.2 Win) . I found information we need create custom collating sequence and create database with this sequence but I can't find informations...
1
by: T | last post by:
Hi I am using Windows 2000(SP4) and recently had MS ACCESS 2000 (9.0.2720) installed. My problem is I cannot create or open any database without getting the following message "Select Collating...
3
by: s_subbarayan | last post by:
Dear all, 1)In one of our implementation for an application we are supposed to collate two linked lists.The actual problem is like this: There are two singularly linked lists, the final output...
5
by: bobwansink | last post by:
Hi, I'm relatively new to programming and I would like to create a C++ multi user program. It's for a project for school. This means I will have to write a paper about the theory too. Does anyone...
0
by: HelmutStoneCorner | last post by:
Hi, I am connected as a german client to a multilanguage server, Regional Options: English, US. Western Europe and US. The W2K Server (Terminal) -version: english(US) runs a french database. My...
17
by: Ron Adam | last post by:
I put together the following module today and would like some feedback on any obvious problems. Or even opinions of weather or not it is a good approach. While collating is not a difficult thing...
0
by: pam | last post by:
We have a customer who would like to see their data sorted in a case- insensitive manner. I've tried several of the out of the box collating sequences (identity, system, compatibility) but none of...
0
by: Frank Swarbrick | last post by:
What might be a good test to demonstrate the difference between the SYSTEM (UNIQUE?) collating sequence and the IDENTITY collating sequence? Thanks, Frank
1
by: anjani132 | last post by:
Hi, I am trying to read Microsoft Excel spreadsheets that were last saved by a person using a chinese language version of excel. Using Asp i am getting an error message. The error message in the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.