473,320 Members | 1,910 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,320 software developers and data experts.

character "grouping" in sort order

In a sorted list, certain characters are grouped together, for example "çb"
(cedille b) comes after "ca" but before "cc".

Is there a built-in way to find out what 'base character', such as C for
cedille, a character belongs to for a given globalization setting?

Nov 20 '05 #1
6 1786
Hi

SortedList are sorted by the keys. Also the keys will be sorted by the
coding value of the key character.

Imports System
Imports System.Collections

Module Module1
Sub Main()
' Creates and initializes a new SortedList.
Dim mySL As New System.Collections.SortedList
mySL.Add("ca", "Hello")
mySL.Add("cedille b", "World")
mySL.Add("cc", "!")
For i As Integer = 0 To mySL.Count - 1
Dim str As String = mySL.GetKey(i)
Dim size As Integer =
System.Text.Encoding.Unicode.GetByteCount(str)
Dim buffs(size - 1) As Byte
buffs = System.Text.Encoding.Unicode.GetBytes(str)
For j As Integer = 0 To size - 1
Console.Write("[{0:X}]", buffs(j))
Next
Console.WriteLine()
Console.WriteLine(mySL.GetKey(i) + ": " & mySL.GetByIndex(i))
Next
End Sub
End Module

So I think you may try to print out the keys' coding value to see if there
are any clue.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #2
On Tue, 03 Aug 2004 05:41:22 GMT, v-******@online.microsoft.com ("Peter
Huang") wrote:
Hi

SortedList are sorted by the keys. Also the keys will be sorted by the
coding value of the key character.


Sorry, I should have been more clear, my problem isn't really related to
sorting.

What I'm doing is filling a treeview with a list of names.

The tree has two levels of nodes: the first level contains the letters of
the alphabet, the second contains all names starting with the same letter.
The problem is finding out what first-level node "special" names have to be
placed in, like "Çakti" (C) and "Önder" (O).

In a sorted list they appear at the right place (as if E and É are the same
letter), that's why I referred to it.
So the question is really simple: does a function exist that you can call
to get the "base character" for a certain character, as in

x = MysteriousFunction("É")

which would return "E" in this example.
I might be able to to roll my own, based on System.Globalization.SortKey,
if I knew what the byte values in the KeyData property mean, but that seems
to be undocumented.

It looks like two characters belong to the same base character if the first
two bytes of their sortkeys are the same, so in the worst case I could scan
the alphabet for that condition, if I was certain that there are no
exceptions.

Nov 20 '05 #3
Hi Lucvdv,

Thank you for your input,
Now I am research the issue, and I will update you with new information
ASAP.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
Hi Lucvdv,

I think so far we do not have such function to do the job. You may try to
build a hashtable to map the special "O" to "O" in your own. So that
everytime you just need to strip off the head letter from the string and
then get their counterpart from the hashtable.

Hope this helps.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5
On Thu, 05 Aug 2004 02:09:45 GMT, v-******@online.microsoft.com ("Peter
Huang") wrote:
Hi Lucvdv,

I think so far we do not have such function to do the job. You may try to
build a hashtable to map the special "O" to "O" in your own. So that
everytime you just need to strip off the head letter from the string and
then get their counterpart from the hashtable.

Hope this helps.


Thanks.
Just in case someone else is interested, this solution I created yesterday
seems to do the job too (it returns the index of the first-level node the
name goes in, 1-26 for A-Z or 0 for non-alphabetic symbols, using
SortInfo):

Private Function NameRootIndex(ByVal Name As String) As Integer
Static Initialized As Boolean
Static LookupTable(26) As Byte

Dim ch As Char = Name.Substring(0, 1).ToUpper
Dim i As Integer = InStr("ABCDEFGHIJKLMNOPQRSTUVWXYZ", ch)

If i > 0 Then
Return i
Else
Dim k As Byte
Dim ci As System.Globalization.CompareInfo _
= Application.CurrentCulture.CompareInfo
If Not Initialized Then
For i = 1 To 26
LookupTable(i) = ci.GetSortKey(Chr(64 + i)).KeyData(1)
Next
Initialized = True
End If
With ci.GetSortKey(ch)
If .KeyData(0) <> 14 Then Return 0
k = .KeyData(1)
End With
For i = 1 To 26
If k = LookupTable(i) Then Return i
Next
End If
Return 0
End Function

Nov 20 '05 #6
Hi Lucvdv,

Thank you for you sharing in the community this will help many others.
Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 21 '05 #7

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

Similar topics

3
by: Rabe | last post by:
Hi all, here a little brain-twister (starting to spoil my weekend if I do not find a solution ... ;-) ) What I want to do is to find a XML-Schema expression that builds a grammar for the...
3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
8
by: Matt | last post by:
Hi all, Thank you for taking the time. I have a database with 45 tables on it. 44 tables are linked to a main table through a one to one relationship. My question is, is there no way i can...
49
by: matty | last post by:
Hi, I recently got very confused (well that's my life) about the "undefined" value. I looked in the FAQ and didn't see anything about it. On...
1
by: ASF | last post by:
Is it possible to create a crystal report graph in which a user selects some parameters---a date range for instance--- AND the table field that they wish to "Group By" then hits the submit button...
1
by: Thomas Qi | last post by:
There is a basic sql below: SELECT CTEnr AS ID, TimeStamp, DatagramSize, Source AS LocalIP, Destination AS RemoteIP, Protocol, Messages, SourcePort AS LocalPort, DestPort AS RemotePort FROM...
35
by: josh | last post by:
Hi, I coded the following but It does not return what I expect, why? #include <iostream> using namespace std; class Other { public: int i;
4
by: jonceramic | last post by:
Hi guys, I have a user who wants to have a report that shows only the 10th value recorded by his equipment. (i.e. His equipment records temperature every 30 seconds, but he only wants to view...
3
BeemerBiker
by: BeemerBiker | last post by:
I tried the following that didnt work "c:\\new.mdb" 'c:\\new.mdb' "c:\\new\.mdb" So far, the only thing that worked is "c:\\new" but I had to rename the destination access database to get rid...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.