1--- 2layout: default 3title: ICU4C 4nav_order: 400 5has_children: true 6--- 7<!-- 8© 2020 and later: Unicode, Inc. and others. 9License & terms of use: http://www.unicode.org/copyright.html 10--> 11 12# ICU4C Readme 13{: .no_toc } 14 15## Contents 16{: .no_toc .text-delta } 17 181. TOC 19{:toc} 20 21--- 22 23 24## Introduction 25 26Today's software market is a global one in which it is desirable to develop and maintain one application (single source/single binary) that supports a wide variety of languages. The International Components for Unicode (ICU) libraries provide robust and full-featured Unicode services on a wide variety of platforms to help this design goal. The ICU libraries provide support for: 27 28* The latest version of the Unicode standard 29* Character set conversions with support for over 220 codepages 30* Locale data for more than 300 locales 31* Language sensitive text collation (sorting) and searching based on the Unicode Collation Algorithm (=ISO 14651) 32* Regular expression matching and Unicode sets 33* Transformations for normalization, upper/lowercase, script transliterations (50+ pairs) 34* Resource bundles for storing and accessing localized information 35* Date/Number/Message formatting and parsing of culture specific input/output formats 36* Calendar specific date and time manipulation 37* Text boundary analysis for finding characters, word and sentence boundaries 38 39ICU has a sister project ICU4J that extends the internationalization capabilities of Java to a level similar to ICU. The ICU C/C++ project is also called ICU4C when a distinction is necessary. 40 41## Getting started 42 43This document describes how to build and install ICU on your machine. For other information about ICU please see the following table of links. 44The ICU homepage also links to related information about writing internationalized software. 45 46**Here are some useful links regarding ICU and internationalization in general.** 47 48 49| ICU, ICU4C & ICU4J Homepage | <https://icu.unicode.org/> | 50| ICU FAQ - Frequently Asked Questions about ICU | <https://unicode-org.github.io/icu/userguide/icu4c/faq> | 51| ICU4J FAQ - Frequently Asked Questions about ICU4J | <https://unicode-org.github.io/icu/userguide/icu4j/faq> | 52| ICU User's Guide | <https://unicode-org.github.io/icu/> | 53| How To Use ICU | <https://unicode-org.github.io/icu/userguide/icu/howtouseicu> | 54| Download ICU Releases | <https://icu.unicode.org/download> | 55| ICU4C API Documentation Online | <https://unicode-org.github.io/icu-docs/apidoc/released/icu4c/> | 56| Online ICU Demos | <https://icu4c-demos.unicode.org/icu-bin/icudemos> | 57| Contacts and Bug Reports/Feature Requests | <https://icu.unicode.org/contacts> | 58 59**Important:** Please make sure you understand the [Copyright and License Information](https://github.com/unicode-org/icu/blob/main/icu4c/LICENSE). 60 61## What Is New In The Current Release? 62 63See the [ICU download page](https://icu.unicode.org/download/) to find the subpage for the current release, including any other changes, bug fixes, known issues, changes to supported platforms and build environments, and migration issues for existing applications migrating from previous ICU releases. 64 65The subpage for the current release will also include an API Change Report, both for ICU4C and ICU4J, for a complete list of APIs added, removed, or changed in this release. 66 67The list of API changes since the previous ICU4C release is available [here](https://htmlpreview.github.io/?https://raw.githubusercontent.com/unicode-org/icu/main/icu4c/APIChangeReport.html). 68 69Changes in previous releases can also be found on the main [ICU download page](https://icu.unicode.org/download) in its version-specific subpages. 70 71## How To Download the Source Code 72 73There are two ways to download ICU releases: 74 75* **Official Release Snapshot:** 76 If you want to use ICU (as opposed to developing it), you should download an official packaged version of the ICU source code. These versions are tested more thoroughly than day-to-day development builds of the system, and they are packaged in zip and tar files for convenient download. These packaged files can be found at [https://icu.unicode.org/download](https://icu.unicode.org/download). 77 The packaged snapshots are named `icu-nnnn.zip` or `icu-nnnn.tgz`, where `nnnn` is the version number. The .zip file is used for Windows platforms, while the .tgz file is preferred on most other platforms. 78 Please unzip this file. 79 > :point_right: **Note**: There may be additional commits on the `maint-*` branch for a particular version that are not included in the prepackaged download files. 80* **GitHub Source Repository:** 81 If you are interested in developing features, patches, or bug fixes for ICU, you should probably be working with the latest version of the ICU source code. You will need to clone and checkout the code from our GitHub repository to ensure that you have the most recent version of all of the files. See our [source repository](https://icu.unicode.org/repository) for details. 82 83## ICU Source Code Organization 84 85In the descriptions below, `<ICU>` is the full path name of the ICU4C directory (the top level directory from the distribution archives) in your file system. You can also view the [ICU Architectural Design](../icu/design.md) section of the User's Guide to see which libraries you need for your software product. You need at least the data (`[lib]icudt`) and the common (`[lib]icuuc`) libraries in order to use ICU. 86 87**The following files describe the code drop.** 88 89| File | Description | 90|-------------|----------------------------------------------------------------| 91| LICENSE | Contains the text of the ICU license | 92 93**The following directories contain source code and data files.** 94 95<table> 96 97 <tr> 98 <th scope="col">Directory</th> 99 100 <th scope="col">Description</th> 101 </tr> 102 103 <tr> 104 <td><i><ICU></i>/source/<b>common</b>/</td> 105 106 <td>The core Unicode and support functionality, such as resource bundles, 107 character properties, locales, codepage conversion, normalization, 108 Unicode properties, Locale, and UnicodeString.</td> 109 </tr> 110 111 <tr> 112 <td><i><ICU></i>/source/<b>i18n</b>/</td> 113 114 <td>Modules in i18n are generally the more data-driven, that is to say 115 resource bundle driven, components. These deal with higher-level 116 internationalization issues such as formatting, collation, text break 117 analysis, and transliteration.</td> 118 </tr> 119 120 <tr> 121 <td><i><ICU></i>/source/<b>layoutex</b>/</td> 122 123 <td>Contains the ICU paragraph layout engine.</td> 124 </tr> 125 126 <tr> 127 <td><i><ICU></i>/source/<b>io</b>/</td> 128 129 <td>Contains the ICU I/O library.</td> 130 </tr> 131 132 <tr> 133 <td><i><ICU></i>/source/<b>data</b>/</td> 134 135 <td> 136 <p>This directory contains the source data in text format, which is 137 compiled into binary form during the ICU build process. It contains 138 several subdirectories, in which the data files are grouped by 139 function. Note that the build process must be run again after any 140 changes are made to this directory.</p> 141 142 <p>If some of the following directories are missing, it's probably 143 because you got an official download. If you need the data source files 144 for customization, then please download the complete ICU source code from <a 145 href="https://icu.unicode.org/repository">the ICU repository</a>.</p> 146 147 <ul> 148 <li><b>in/</b> A directory that contains a pre-built data library for 149 ICU. A standard source code package will contain this file without 150 several of the following directories. This is to simplify the build 151 process for the majority of users and to reduce platform porting 152 issues.</li> 153 154 <li><b>brkitr/</b> Data files for character, word, sentence, title 155 casing and line boundary analysis.</li> 156 157 <li><b>coll/</b> Data for collation tailorings.</li> 158 159 <li><b>locales/</b> These .txt files contain ICU language and 160 culture-specific localization data. Two special bundles are 161 <b>root</b>, which is the fallback data and parent of other bundles, 162 and <b>index</b>, which contains a list of installed bundles. 163 Some of the locale data is split out into the type-specific 164 directories curr, lang, region, unit, and zone, described below.</li> 165 166 <li><b>curr/</b> Locale data for currency symbols and names (including 167 plural forms).</li> 168 169 <li><b>lang/</b> Locale data for names of languages, scripts, and locale 170 key names and values.</li> 171 172 <li><b>region/</b> Locale data for names of regions.</li> 173 174 <li><b>unit/</b> Locale data for measurement unit patterns and 175 names.</li> 176 177 <li><b>zone/</b> Locale data for time zone names.</li> 178 179 <li><b>mappings/</b> Here are the code page converter tables. These 180 .ucm files contain mappings to and from Unicode. These are compiled 181 into .cnv files. <b>convrtrs.txt</b> is the alias mapping table from 182 various converter name formats to ICU internal format and vice versa. 183 It produces cnvalias.icu. The makefiles <b>ucmfiles.mk, 184 ucmcore.mk,</b> and <b>ucmebcdic.mk</b> contain the list of 185 converters to be built.</li> 186 187 <li><b>translit/</b> This directory contains transliterator rules as 188 resource bundles, and the special bundle <b>translit_index</b> which 189 lists the system transliterator aliases.</li> 190 191 <li><b>unidata/</b> This directory contains the Unicode data files. 192 Please see <a href= 193 "http://www.unicode.org/">http://www.unicode.org/</a> for more 194 information.</li> 195 196 <li><b>misc/</b> The misc directory contains other data files which 197 did not fit into the above categories, including time zone 198 information, region-specific data, and other data derived from CLDR 199 supplemental data.</li> 200 201 <li><b>out/</b> This directory contains the assembled memory mapped 202 files.</li> 203 204 <li><b>out/build/</b> This directory contains intermediate (compiled) 205 files, such as .cnv, .res, etc.</li> 206 </ul> 207 208 <p>If you are creating a special ICU build, you can set the ICU_DATA 209 environment variable to the out/ or the out/build/ directories, but 210 this is generally discouraged because most people set it incorrectly. 211 You can view the <a href= 212 "https://unicode-org.github.io/icu/userguide/icu_data">ICU Data 213 Management</a> section of the ICU User's Guide for details.</p> 214 </td> 215 </tr> 216 217 <tr> 218 <td><i><ICU></i>/source/test/<b>intltest</b>/</td> 219 220 <td>A test suite including all C++ APIs. For information about running 221 the test suite, see the build instructions specific to your platform 222 later in this document.</td> 223 </tr> 224 225 <tr> 226 <td><i><ICU></i>/source/test/<b>cintltst</b>/</td> 227 228 <td>A test suite written in C, including all C APIs. For information 229 about running the test suite, see the build instructions specific to your 230 platform later in this document.</td> 231 </tr> 232 233 <tr> 234 <td><i><ICU></i>/source/test/<b>iotest</b>/</td> 235 236 <td>A test suite written in C and C++ to test the icuio library. For 237 information about running the test suite, see the build instructions 238 specific to your platform later in this document.</td> 239 </tr> 240 241 <tr> 242 <td><i><ICU></i>/source/test/<b>testdata</b>/</td> 243 244 <td>Source text files for data, which are read by the tests. It contains 245 the subdirectories <b>out/build/</b> which is used for intermediate 246 files, and <b>out/</b> which contains <b>testdata.dat.</b></td> 247 </tr> 248 249 <tr> 250 <td><i><ICU></i>/source/<b>tools</b>/</td> 251 252 <td>Tools for generating the data files. Data files are generated by 253 invoking <i><ICU></i>/source/data/build/makedata.bat on Win32 or 254 <i><ICU></i>/source/make on UNIX.</td> 255 </tr> 256 257 <tr> 258 <td><i><ICU></i>/source/<b>samples</b>/</td> 259 260 <td>Various sample programs that use ICU</td> 261 </tr> 262 263 <tr> 264 <td><i><ICU></i>/source/<b>extra</b>/</td> 265 266 <td>Non-supported API additions. Currently, it contains the 'uconv' tool 267 to perform codepage conversion on files.</td> 268 </tr> 269 270 <tr> 271 <td><i><ICU></i>/<b>packaging</b>/</td> 272 273 <td>This directory contain scripts and tools for packaging the final 274 ICU build for various release platforms.</td> 275 </tr> 276 277 <tr> 278 <td><i><ICU></i>/source/<b>config</b>/</td> 279 280 <td>Contains helper makefiles for platform specific build commands. Used 281 by 'configure'.</td> 282 </tr> 283 284 <tr> 285 <td><i><ICU></i>/source/<b>allinone</b>/</td> 286 287 <td>Contains top-level ICU workspace and project files, for instance to 288 build all of ICU under one MSVC project.</td> 289 </tr> 290 291 <tr> 292 <td><i><ICU></i>/<b>include</b>/</td> 293 294 <td>Contains the headers needed for developing software that uses ICU on 295 Windows.</td> 296 </tr> 297 298 <tr> 299 <td><i><ICU></i>/<b>lib</b>/</td> 300 301 <td>Contains the import libraries for linking ICU into your Windows 302 application.</td> 303 </tr> 304 305 <tr> 306 <td><i><ICU></i>/<b>bin</b>/</td> 307 308 <td>Contains the libraries and executables for using ICU on Windows.</td> 309 </tr> 310 </table> 311 312 313 314## How To Build And Install ICU 315 316See the page on [building ICU4C](./build). 317 318## How To Package ICU 319 320See the page on [packaging ICU4C](./packaging). 321 322## Important Notes About Using ICU 323 324### Using ICU in a Multithreaded Environment 325 326Some versions of ICU require calling the `u_init()` function from `uclean.h` to ensure that ICU is initialized properly. In those ICU versions, `u_init()` must be called before ICU is used from multiple threads. There is no harm in calling `u_init()` in a single-threaded application, on a single-CPU machine, or in other cases where `u_init()` is not required. 327 328In addition to ensuring thread safety, `u_init()` also attempts to load at least one ICU data file. Assuming that all data files are packaged together (or are in the same folder in files mode), a failure code from `u_init()` usually means that the data cannot be found. In this case, the data may not be installed properly, or the application may have failed to call `udata_setCommonData()` or `u_setDataDirectory()` which specify to ICU where it can find its data. 329 330Since `u_init()` will load only one or two data files, it cannot guarantee that all of the data that an application needs is available. It cannot check for all data files because the set of files is customizable, and some ICU services work without loading any data at all. An application should always check for error codes when opening ICU service objects (using `ucnv_open()`, `ucol_open()`, C++ constructors, etc.). 331 332#### ICU 3.4 and later 333 334ICU 3.4 self-initializes properly for multi-threaded use. It achieves this without performance penalty by hardcoding the core Unicode properties data, at the cost of some flexibility. (For details see Jitterbug 4497.) 335 336`u_init()` can be used to check for data loading. It tries to load the converter alias table (`cnvalias.icu`). 337 338#### ICU 2.6..3.2 339 340These ICU versions require a call to `u_init()` before multi-threaded use. The services that are directly affected are those that don't have a service object and need to be fast: normalization and character properties. 341 342`u_init()` loads and initializes the data files for normalization and character properties (`unorm.icu` and `uprops.icu`) and can therefore also be used to check for data loading. 343 344#### ICU 2.4 and earlier 345 346ICU 2.4 and earlier versions were not prepared for multithreaded use on multi-CPU platforms where the CPUs implement weak memory coherency. These CPUs include: Power4, Power5, Alpha, Itanium. `u_init()` was not defined yet. 347 348#### Using ICU in a Multithreaded Environment on HP-UX 349 350When ICU is built with aCC on HP-UX, the [`-AA`](http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801?ciid=eb08b3f1eee02110b3f1eee02110275d6e10RCRD) compiler flag is used. It is required in order to use the latest `<iostream>` API in a thread safe manner. This compiler flag affects the version of the C++ library being used. Your applications will also need to be compiled with `-AA` in order to use ICU. 351 352#### Using ICU in a Multithreaded Environment on Solaris 353 354##### Linking on Solaris 355 356In order to avoid synchronization and threading issues, developers are **suggested** to strictly follow the compiling and linking guidelines for multithreaded applications, specified in the following SUn Solaris document available from Oracle. Most notably, pay strict attention to the following statements from Sun: 357 358> To use libthread, specify `-lthread` before `-lc` on the ld command line, or last on the cc command line. 359> 360> To use libpthread, specify `-lpthread` before `-lc` on the ld command line, or last on the cc command line. 361 362Failure to do this may cause spurious lock conflicts, recursive mutex failure, and deadlock. 363 364Source: "_Multithreaded Programming Guide, Compiling and Debugging_", Sun Microsystems, 2002 365[https://docs.oracle.com/cd/E19683-01/806-6867/compile-74765/index.html](https://docs.oracle.com/cd/E19683-01/806-6867/compile-74765/index.html) 366 367Note, a version of that chapter from a 2008 document update covering both Solaris 9 and Solaris 10 is available here: 368[http://docs.oracle.com/cd/E19253-01/816-5137/compile-94179/index.html](http://docs.oracle.com/cd/E19253-01/816-5137/compile-94179/index.html) 369 370### Windows Platform 371 372If you are building on the Windows platform, it is important that you understand a few of the following build details. 373 374#### DLL directories and the PATH setting 375 376As delivered, the International Components for Unicode build as several DLLs, which are placed in the `<ICU>\bin64` directory. You must add this directory to the PATH environment variable in your system, or any executables you build will not be able to access International Components for Unicode libraries. Alternatively, you can copy the DLL files into a directory already in your PATH, but we do not recommend this. You can wind up with multiple copies of the DLL and wind up using the wrong one. 377 378#### Changing your PATH 379 380##### Windows 2000/XP and above 381 382Use the System Icon in the Control Panel. Pick the "Advanced" tab. Select the "Environment Variables..." button. Select the variable `PATH` in the lower box, and select the lower "Edit..." button. In the "Variable Value" box, append the string `;<ICU>\bin64` to the end of the path string. If there is nothing there, just type in `<ICU>\bin64`. Click the Set button, then the OK button. 383 384> :point_right: **Note**: When packaging a Windows application for distribution and installation on user systems, copies of the ICU DLLs should be included with the application, and installed for exclusive use by the application. This is the only way to insure that your application is running with the same version of ICU, built with exactly the same options, that you developed and tested with. Refer to Microsoft's guidelines on the usage of DLLs, or search for the phrase "DLL hell" on [msdn.microsoft.com](http://msdn.microsoft.com/). 385 386### UNIX Type Platform 387 388If you are building on a UNIX platform, and if you are installing ICU in a non-standard location, you may need to add the location of your ICU libraries to your `LD_LIBRARY_PATH` or `LIBPATH` environment variable (or the equivalent runtime library path environment variable for your system). The ICU libraries may not link or load properly without doing this. 389 390> :point_right: **Note**: If you do not want to have to set this variable, you may instead use the `--enable-rpath` option at configuration time. This option will instruct the linker to always look for the libraries where they are installed. You will need to use the appropriate linker options when linking your own applications and libraries against ICU, too. Please refer to your system's linker manual for information about runtime paths. The use of rpath also means that when building a new version of ICU you should not have an older version installed in the same place as the new version's installation directory, as the older libraries will used during the build, instead of the new ones, likely leading to an incorrectly build ICU. This is the proper behavior of rpath. 391 392## Platform Dependencies 393 394### Porting To A New Platform 395 396If you are using ICU's Makefiles to build ICU on a new platform, there are a few places where you will need to add or modify some files. If you need more help, you can always ask the [icu-support mailing list](https://icu.unicode.org/contacts). Once you have finished porting ICU to a new platform, it is recommended that you contribute your changes back to ICU via the icu-support mailing list. This will make it easier for everyone to benefit from your work. 397 398#### Data For a New Platform 399 400For some people, it may not be necessary for completely build ICU. Most of the makefiles and build targets are for tools that are used for building ICU's data, and an application's data (when an application uses ICU resource bundles for its data). 401 402Data files can be built on a different platform when both platforms share the same endianness and the same charset family. This assertion does not include platform dependent DLLs/shared/static libraries. For details see the User Guide [ICU Data](../icu_data) chapter. 403 404ICU 3.6 removes the requirement that ICU be completely built in the native operating environment. It adds the icupkg tool which can be run on any platform to turn binary ICU data files from any one of the three formats into any one of the other data formats. This allows a application to use ICU data built anywhere to be used for any other target platform. 405 406**WARNING!** Building ICU without running the tests is not recommended. The tests verify that ICU is safe to use. It is recommended that you try to completely port and test ICU before using the libraries for your own application. 407 408#### Adapting Makefiles For a New Platform 409 410Try to follow the build steps from the [UNIX](#how-to-build-and-install-on-unix) build instructions. If the configure script fails, then you will need to modify some files. Here are the usual steps for porting to a new platform: 411 4121. Create an mh file in `<ICU>/source/config/`. You can use mh-linux or a similar mh file as your base configuration. 4132. Modify `<ICU>/source/aclocal.m4` to recognize your platform's mh file. 4143. Modify `<ICU>/source/configure.in` to properly set your **platform** C Macro define. 4154. Run [autoconf](http://www.gnu.org/software/autoconf/) in `<ICU>/source/` without any options. The autoconf tool is standard on most Linux systems. 4165. If you have any optimization options that you want to normally use, you can modify `<ICU>/source/runConfigureICU` to specify those options for your platform. 4176. Build and test ICU on your platform. It is very important that you run the tests. If you don't run the tests, there is no guarantee that you have properly ported ICU. 418 419### Platform Dependent Implementations 420 421The platform dependencies have been mostly isolated into the following files in the common library. This information can be useful if you are porting ICU to a new platform. 422 423* **unicode/platform.h.in** (autoconf'ed platforms) 424 **unicode/p_XXXX_.h** (others: pwin32.h, ppalmos.h, ..): Platform-dependent typedefs and defines: 425 * Generic types like `UBool`, `int8_t`, `int16_t`, `int32_t`, `int64_t`, `uint64_t` etc. 426 * `U_EXPORT` and `U_IMPORT` for specifying dynamic library import and export 427 * String handling support for the `char16_t` and `wchar_t` types. 428* **unicode/putil.h, putil.c**: platform-dependent implementations of various functions that are platform dependent: 429 * `uprv_isNaN`, `uprv_isInfinite`, `uprv_getNaN` and `uprv_getInfinity` for handling special floating point values. 430 * `uprv_tzset`, `uprv_timezone`, `uprv_tzname` and `time` for getting platform specific time and time zone information. 431 * `u_getDataDirectory` for getting the default data directory. 432 * `uprv_getDefaultLocaleID` for getting the default locale setting. 433 * `uprv_getDefaultCodepage` for getting the default codepage encoding. 434* **umutex.h, umutex.c**: Code for doing synchronization in multithreaded applications. If you wish to use International Components for Unicode in a multithreaded application, you must provide a synchronization primitive that the classes can use to protect their global data against simultaneous modifications. We already supply working implementations for many platforms that ICU builds on. 435* **umapfile.h, umapfile.c**: functions for mapping or otherwise reading or loading files into memory. All access by ICU to data from files makes use of these functions. 436* Using platform specific `#ifdef` macros are highly discouraged outside of the scope of these files. When the source code gets updated in the future, these `#ifdef`'s can cause testing problems for your platform. 437 438* * * 439 440Copyright © 2016 and later: Unicode, Inc. and others. License & terms of use: [http://www.unicode.org/copyright.html](http://www.unicode.org/copyright.html) 441Copyright © 1997-2016 International Business Machines Corporation and others. All Rights Reserved. 442