• Home
  • History
  • Annotate
  • only in /external/icu/icu4c/source/samples/legacy/
NameDateSize

..10-Aug-20184 KiB

legacy.cpp10-Aug-20183 KiB

legacy.vcxproj10-Aug-201814.3 KiB

legacy.vcxproj.filters10-Aug-20181 KiB

Makefile10-Aug-20182.2 KiB

newcol.cpp10-Aug-20182.8 KiB

oldcol.cpp10-Aug-20183.2 KiB

README10-Aug-20183.4 KiB

README

1Copyright (C) 2016 and later: Unicode, Inc. and others.
2License & terms of use: http://www.unicode.org/copyright.html#License
3
4Copyright (c) 2002, International Business Machines Corporation and others. All Rights Reserved.
5This example demonstrates running an instance of  ICU 1.8.1. together with a current version of ICU. It only tests u_getVersion and several collation APIs. 
6
7Generally, one should be able to simultaneously use one or more versions of ICU 2.0 or higher and one version of ICU 1.8.1 or lower. 
8
9What is it all about: Let's say you have a 10 Tb database indexed using ICU 1.8.1. sortkeys. New ICU comes out, with neat new features you would like to use, but also with new sortkeys and you don't care to reindex your 10 Tb database. What to do then??? You can use ICU 1.8.1. in one of your compilation units and current version in all the others. So, you can use old collation until you decide to reindex. 
10
11You cannot mix two versions of ICU in the same compilation unit. You cannot automatically use more than one legacy version of ICU.
12
13In order to make the compilation unit use old version of ICU, you have to do a couple of things:
141) change it's include path so that it includes header files from the old versions
152) explicitly add old libraries to the linker.
163) make sure old data can be found (if legacy code needs data).
17
18Building and running of the example:
19
20Linux:
21To make it work, you should build and install both the current ICU and ICU 1.8.1. Put both data libraries to wherever ICU_DATA points (usually it is $(prefix)/share/icu/$(icu_version)/). If data libraries are used, then check for $(prefix)/lib/icu/1.8.1 which should contain libicudata.so and libicudt18*.so
222. Copy libicuuc.so.18* and libicui18n.so.18* to $(prefix)/lib directory, together with current libraries). 
233. Should work on other Unixes.
24
25
26Change $ICU_PREFIX to point to the current installation, and $ICU_LEGACY to point to 1.8.1 installation. $ICU_LEGACY is needed solely to access the 1.8.1 include directory through $LEGACY_INCLUDE variable, so if you want to move the 1.8.1. include directory, you can set $LEGACY_INCLUDE directly to that directory.
27
28Run make check. You should get two different libraries running at the same time.
29
30Win32:
31Build both current ICU and ICU 1.8.1. Take icuuc18.dll, icuin18.dll and icudt18l.dll and put them somewhere in PATH (a sane place would be wherever current dlls go). 
32
33Edit the include directory for oldcol.cpp so that it points to the include directory of ICU 1.8.1.
34Edit the two library entries with path so that they point to .lib files for your version of ICU.
35
36Hit F7, followed by ctrl-F5.
37
38Troubleshooting (all platforms):
39Sample won't compile: this is quite unlikely, but the most probable reason is that include files cannot be found. 
40Sample won't link: The path for 1.8.1. libraries is broken. Edit it so that it  reflects the path to your libraries.
41Linker says: "Undefined symbol u_getVersion()" (or something similar): path to 1.8.1. libraries is bad.
42Linker says: "Undefined symbol u_getVersion()_X_Y" (or something similar): path to current libraries is bad.
43Legacy crashes horribly: Sorry, didn't put any error checking. If legacy crashes that's most probably because it cannot find the data libraries. You can see which data library is not found by the part of the program that is running. Make sure program can find tha data library either by putting it where ever ICU_DATA points to OR by putting the DLL version of the data library somewhere on your PATH.
44
45