3

Has anyone used the ICU ( see http://site.icu-project.org/ ) DLLs from Delphi?

Specifically I'm interested in the Code Page Conversion and Collation functions.

Looking at the header files it would appear that they are mostly in C++ using classes, so without having done much research yet, I would assume that it's necessary to create a simple wrapper around this that exports simple functions which can easily be imported in Delphi.

Has anyone done any work for that yet?

Or can anyone recommend a different solution for Delphi that has similar extensive coverage for codepages and collation orders?

Thorsten Engler
  • 2,333
  • 12
  • 13
  • 1
    Don't modern Delphi's already do codepage conversions? – David Heffernan Mar 29 '11 at 13:33
  • Yes, sure. But this depends on calling windows api functions. The data backing codepage translations and collation order has been updated with every windows version. So if you sort a list of strings on one version of Windows and save it into a file. Then open that list on a different version of windows and try to perform a binary search in the supposedly sorted list, it's hit and miss as the string comparisons might now return different results then when the list was originally sorted. Using ICU would allow a consistent sort order independent of the OS version. – Thorsten Engler Mar 29 '11 at 14:01
  • if sorting is the only problem, can't you simply sort the file again? I'm thinking the sorting order was changed for a reason: are you sure ICU doesn't include the same changes from version to version? If it doesn't, and there's a difference between ICU and Windows, are you sure the ICU version is correct and Windows is wrong? I'm sure Microsoft has its faults, but I'm also sure it's used in every country and every language: if a change was made from version A to version B, it's probably because native speakers requested it. – Cosmin Prund Mar 30 '11 at 19:21
  • Yes, that is what I'm implementing right now, use GetNLSVersion for the used locale and store that in the file (a NexusDB table) and if on opening the file GetNLSVersion returns a different version the table is put into read-only mode and it's not possible to activate any of the affected indices. But I don't think most of our customers will appreciate having to pack all their tables after copying them from one computer to another. So I want to offer ICU as an alternative option (the user is obviously in control of deciding what to use when creating the table). – Thorsten Engler Mar 30 '11 at 23:10
  • ICU has C interfaces with service objects for many things. I don't know in this case, but the C interfaces are often easier to bridge to another language than the C++. It depends, though. For example, ICU's C++ interfaces mostly use its string class, whereas the C interfaces use UTF-16 wide character arrays. (I know this is an old question,but for the record…) – Steven R. Loomis Apr 26 '13 at 01:21

1 Answers1

2

I don't use it, but there's a very complete translation called ICU4PAS that wraps the DLLs and provides a nice Delphi-based interface.

Zoë Peterson
  • 13,094
  • 2
  • 44
  • 64
  • Thanks, I'll check that out in detail tomorrow. The only thing that I'm worried about is that the wrapper hasn't been updated since 2007, and ICU has been updated quite often since. As the wrappers seem to mess around with VMT offsets at first glance, I assume there will be serious issue if any changes have been made to ICU. Do you know of anyone who is using these wrappers with the current version of ICU? – Thorsten Engler Mar 29 '11 at 14:59
  • Sorry, no. Given the description I doubt it will work with new versions as-is, but I suspect the updates would be fairly mechanical. – Zoë Peterson Mar 29 '11 at 15:27
  • Unfortunately, it seems it would take a huge amount of work to get that to work with the current version of ICU, so this is not a good option. – Thorsten Engler Mar 30 '11 at 08:50