472,372 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,372 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 2056
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: Johno34 | last post by:
I have this click event on my form. It speaks to a Datasheet Subform Private Sub Command260_Click() Dim r As DAO.Recordset Set r = Form_frmABCD.Form.RecordsetClone r.MoveFirst Do If...
0
by: jack2019x | last post by:
hello, Is there code or static lib for hook swapchain present? I wanna hook dxgi swapchain present for dx11 and dx9.

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.