473,796 Members | 2,916 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2199
In <bv***********@ av9195.comtv.ru > Victor Nazarov <vv*****@mail.r u> 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.r u> 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
3882
by: * ProteanThread * | last post by:
but depends upon the clique: http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=954drf%24oca%241%40agate.berkeley.edu&rnum=2&prev=/groups%3Fq%3D%2522cross%2Bposting%2Bversus%2Bmulti%2Bposting%2522%26ie%3DUTF-8%26oe%3DUTF-8%26hl%3Den ...
1
2675
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 how do this. Can anyone tell me how create case-insensitive collating sequence (sample or link) and how set this sequence in CREATE DATABASE command? Thanks in advance.
1
4625
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 Sequence not supported by the operating system". I have searched around this and other forums and the only suggestion is to update the CollatingSequence key in the registry which I have done but my problem still exists.
3
3274
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 will be a "perfectly shuffle" of the lists together into a single list. The new list should consist of consecutively alternating nodes from both lists.Note that both these linked lists have same kind of data structure in their nodes.
5
5771
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 know a good place to start looking for some theory on the subject of multi user applications? I know only bits and pieces, like about transactions, but a compendium of possible approches to multi user programming would be very appreciated!
0
2107
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 regional options are: General: English, US, (Keybd: german). I create a new database and, opening the table or going to the options, I get: An error occurred and this feature is no longer functioning properly - then: Selected collating sequence...
17
1905
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 to do for experienced programmers, I have seen quite a lot of poorly sorted lists in commercial applications, so it seems it would be good to have an easy to use ready made API for collating. I tried to make this both easy to use and flexible. ...
0
1611
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 them result in the ordering they would like to see. Has anyone used the Create Database API to pass in a custom collating sequence that would result in a case-insensitive sort (ie a=A for weight)? Are there samples of how to do this? Any...
0
1856
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
6227
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 browser is "Selected collating sequence not supported by the operating system. (Microsoft JET Database Engine). We found one work around for this issue by creating a batch script that would open these spreadsheet with an English Language version of excel...
0
9685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10467
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10201
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7558
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6802
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5582
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4130
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3744
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2931
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.