### Start QSH Session Source: https://unicode-org.github.io/icu/userguide/icu4c/build Command to initiate the QSHELL environment. ```cl qsh ``` -------------------------------- ### Get Algorithm Range Start Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/UCharacterName.java.html Retrieves the starting codepoint of a specified algorithm range. ```java public int getAlgorithmStart(int index) { return m_algorithm_[index].m_rangestart_; } ``` -------------------------------- ### Create New Maven Project Source: https://unicode-org.github.io/icu/userguide/format_parse/messages/try-mf2.html Use this command to generate a new Maven project with the quickstart archetype. Navigate into the created directory. ```bash mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=hello_icu_mf2 -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.5 -DinteractiveMode=false cd hello_icu_mf2 ``` -------------------------------- ### Get Dictionary Categories Start Index Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/RBBISetBuilder.java.html Retrieves the starting index for dictionary-defined character categories. ```java int getDictCategoriesStart() { return fDictCategoriesStart; } ``` -------------------------------- ### Placeholder Configuration Examples Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.message2/MessageFormatter.java.html Examples of mapping runtime values to placeholders within message patterns. ```java arguments.put("name", "John") ``` ```text {$name} ``` ```java arguments.put("exp", new Date(…)) ``` ```text {$exp :datetime skeleton=year=numeric month=short day=numeric weekday=short} {$exp :datetime dateStyle=full} ``` ```java arguments.put("val", 3.141592653) ``` ```text {$val} {$val :number minimumFractionDigits=5} ``` ```text {|123456789.531| :number} ``` -------------------------------- ### Get Code Point Start Index Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/CaseMapImpl.java.html Retrieves the starting index of the most recently processed code point. ```java public int getCPStart() { return cpStart; } ``` -------------------------------- ### Get All Installed Locales in Java Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/ULocale.java.html Retrieves a clone of the array of all installed ULocales. This is equivalent to calling getAvailableLocalesByType with AvailableType.DEFAULT. ```java public static ULocale[] getAvailableLocales() { return ICUResourceBundle.getAvailableULocales().clone(); } ``` -------------------------------- ### Open, Prepare, and Close StringPrep Profile in C++ Source: https://unicode-org.github.io/icu/userguide/strings/stringprep.html Demonstrates the basic usage of the StringPrep service in C++. It shows how to open a StringPrep profile, prepare a source string according to the profile's rules, and then close the profile. Ensure the profile object is reused for performance instead of opening and closing it repeatedly. ```cpp UErrorCode status = U_ZERO_ERROR; UParseError parseError; /* open the StringPrep profile */ UStringPrepProfile* nameprep = usprep_open("/usr/joe/mydata", "nfscsi", &status); if(U_FAILURE(status)) { /* handle the error */ } /* prepare the string for use according * to the rules specified in the profile */ int32_t retLen = usprep_prepare(src, srcLength, dest, destCapacity, USPREP_ALLOW_UNASSIGNED, nameprep, &parseError, &status); /* close the profile */ usprep_close(nameprep); ``` -------------------------------- ### Get Era Start Year Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/EraRules.java.html Retrieves the start year for a given era code. If the era code is not found or has no defined start date, an IllegalArgumentException is thrown. Returns the year component of the start date. ```java public int getStartYear(int eraCode) { int startDate = 0; if (eraCode >= minEra) { int startIdx = eraCode - minEra; if (startIdx < startDates.length) { startDate = startDates[startIdx]; } } if (isSet(startDate)) { int[] fields = decodeDate(startDate, null); return fields[0]; } // We did not find the requested eraCode in our data throw new IllegalArgumentException("eraCode is not found in our data"); } ``` -------------------------------- ### Example Output Format Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.math/MathContext.java.html The expected string format for context settings. ```text digits=9 form=SCIENTIFIC lostDigits=0 roundingMode=ROUND_HALF_UP ``` -------------------------------- ### Install Docker on Ubuntu Source: https://unicode-org.github.io/icu/userguide/dev/fuzzer_targets.html Install the Docker engine on an Ubuntu system. ```bash sudo apt install docker ``` -------------------------------- ### Get Script from Codepoint Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.lang/UScript.java.html Gets the script code associated with a given codepoint. For example, it returns UScript.MALAYAM for codepoint 0x0D02. ```APIDOC ## GET /getScript ### Description Gets the script code associated with the given codepoint. Returns UScript.MALAYAM given 0x0D02. ### Method GET ### Endpoint /getScript ### Parameters #### Query Parameters - **codepoint** (int) - Required - UChar32 codepoint ### Response #### Success Response (200) - **scriptCode** (int) - The script code #### Response Example ```json { "scriptCode": 130 } ``` #### Error Response (400) - **errorMessage** (String) - Error message indicating an invalid codepoint. #### Error Response Example ```json { "errorMessage": "Invalid codepoint: -1" } ``` ``` -------------------------------- ### Initialize StringPrep Profile in Java Source: https://unicode-org.github.io/icu/userguide/strings/stringprep.html Demonstrates loading a StringPrep profile from a data stream and preparing input strings. ```java private static final StringPrep nfscsi = null; //singleton instance private static final NFSCSIStringPrep prep=new NFSCSIStringPrep(); private NFSCSIStringPrep() { try { InputStream nfscsiFile = TestUtil.getDataStream("nfscsi.spp"); nfscsi = new StringPrep(nfscsiFile); nfscsiFile.close(); } catch(IOException e) { throw new RuntimeException(e.toString()); } } private static byte[] prepare(byte[] src, StringPrep prep) throws StringPrepParseException, UnsupportedEncodingException { String s = new String(src, "UTF-8"); UCharacterIterator iter = UCharacterIterator.getInstance(s); StringBuffer out = prep.prepare(iter,StringPrep.DEFAULT); return out.toString().getBytes("UTF-8"); } ``` -------------------------------- ### GET getTimeZoneRules(long start) Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/BasicTimeZone.java.html Retrieves the array of TimeZoneRule objects applicable to the time zone since a specified start time. ```APIDOC ## GET getTimeZoneRules(long start) ### Description Returns the array of TimeZoneRule objects which represent the rule of this time zone object since the specified start time. ### Method GET ### Parameters #### Query Parameters - **start** (long) - Required - The start time in milliseconds (inclusive). ### Response - **TimeZoneRule[]** (array) - An array of TimeZoneRule objects representing the time zone since the start time. ``` -------------------------------- ### Run Jekyll Server Source: https://unicode-org.github.io/icu/userguide/dev/editing.html Full sequence of commands to initialize the environment and start the local Jekyll server. ```bash rbenv init # OR: eval "$(rbenv init -)" rbenv shell cd /docs # change to User Guide docs root directory bundle update bundle exec jekyll server ``` -------------------------------- ### Get Start Code Point of a Range Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/CodePointMap.java.html Retrieves the starting code point of a range. This method is stable since ICU 63. ```java public int getStart() { return start; } ``` -------------------------------- ### Get Run Start Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/Bidi.java.html Returns the index of the character at the start of the nth logical run. Requires a successful call to setPara or setLine. ```java public int getRunStart(int run) { verifyValidParaOrLine(); BidiLine.getRuns(this); ``` -------------------------------- ### Initialize Visual C++ Environment Source: https://unicode-org.github.io/icu/userguide/icu4c/build Run these batch files in the Windows Command Prompt to set up the compiler environment for 32-bit or 64-bit builds. ```batch C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat ``` ```batch C:\Program Files (x86)\Microsoft Visual Studio 14\VC\bin\x86_amd64\vcvarsx86_amd64.bat ``` -------------------------------- ### Get Subsequence Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/StringSegment.java.html Returns a CharSequence representing a subsequence of the StringSegment. The start and end indices are relative to the segment's start offset. ```java public CharSequence subSequence(int start, int end) { return str.subSequence(start + this.start, end + this.start); } ``` -------------------------------- ### Any-Publishing Transliterator example Source: https://unicode-org.github.io/icu/userguide/transforms/general A complex example demonstrating variable definitions and conversion rules to format ASCII text for publishing. ```text # Variables $single = \' ; $space = ' ' ; $double = " ; $back = \` ; $tab = '\u0008' ; # the following is for spaces, line ends, (, [, {, ... $makeRight = [[:separator:][:start punctuation:][:initial punctuation:]] ; # fix UNIX quotes $back $back > “ ; # generate right d.q.m. (double quotation mark) $back > ‘ ; # fix typewriter quotes, by context $makeRight { $double <> “ ; # convert a double to right d.q.m. after certain chars ^ { $double > “ ; # convert a double at the start of the line. $double <> ” ; # otherwise convert to a left q.m. $makeRight {$single} <> ‘ ; # do the same for s.q.m.s ^ {$single} > ‘ ; $single <> ’; # fix multiple spaces and hyphens $space {$space} > ; # collapse multiple spaces '--' <> — ; # convert fake dash into real one ``` -------------------------------- ### Instance Initialization Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/DateTimePatternGenerator.html Methods for creating and initializing instances. ```APIDOC ## getInstance() ### Description Creates a new instance of the class. ### Method N/A (Assumed to be a static method or constructor) ### Endpoint N/A ## getInstance(ULocale) ### Description Creates a new instance of the class with a specified ULocale. ### Method N/A (Assumed to be a static method or constructor) ### Endpoint N/A ## getInstance(Locale) ### Description Creates a new instance of the class with a specified Locale. ### Method N/A (Assumed to be a static method or constructor) ### Endpoint N/A ``` -------------------------------- ### GET /getRowStart Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/PropsVectors.java.html Retrieves the start codepoint for a specific row. ```APIDOC ## GET /getRowStart ### Description Returns the start codepoint defined in the specified row index. ### Parameters #### Query Parameters - **rowIndex** (int) - Required - The index of the row. ### Response #### Success Response (200) - **startCodepoint** (int) - The starting codepoint value. ``` -------------------------------- ### Implementing Factory Functions with LocalPointer Source: https://unicode-org.github.io/icu/userguide/dev/codingguidelines.html This example demonstrates the recommended pattern for factory functions using LocalPointer to ensure proper cleanup of adopted objects even when errors occur. ```cpp Calendar* Calendar::createInstance(TimeZone* zone, UErrorCode& errorCode) { LocalPointer adoptedZone(zone); if(U_FAILURE(errorCode)) { // The adoptedZone destructor deletes the zone. return nullptr; } // since the Locale isn't specified, use the default locale LocalPointer c(new GregorianCalendar(zone, Locale::getDefault(), errorCode), errorCode); // LocalPointer will set a U_MEMORY_ALLOCATION_ERROR if // new GregorianCalendar() returns nullptr. if (c.isValid()) { // c adopted the zone. adoptedZone.orphan(); } if (U_FAILURE(errorCode)) { // If c was constructed, then the c destructor deletes the Calendar, // and the Calendar destructor deletes the adopted zone. return nullptr; } return c.orphan(); } ``` -------------------------------- ### GET /calendars/ulocales Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/Calendar.java.html Retrieves the list of ULocales for which Calendars are installed. ```APIDOC ## GET /calendars/ulocales ### Description Returns the list of ULocales for which Calendars are installed. ### Method GET ### Endpoint /calendars/ulocales ### Response #### Success Response (200) - **ulocales** (ULocale[]) - List of installed ULocales ``` -------------------------------- ### GET /calendars/locales Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/Calendar.java.html Retrieves the list of locales for which Calendars are installed. ```APIDOC ## GET /calendars/locales ### Description Returns the list of locales for which Calendars are installed. ### Method GET ### Endpoint /calendars/locales ### Response #### Success Response (200) - **locales** (Locale[]) - List of installed locales ``` -------------------------------- ### Manage Converter Life Cycle Source: https://unicode-org.github.io/icu/userguide/conversion/converters.html Demonstrates the standard sequence of opening, using, and closing a converter. ```C UConverter *conv = ucnv_open("shift_jis", &status); ``` ```C int32_t len = ucnv_fromUChars(conv, target, targetSize, source, u_strlen(source), &status); ``` ```C ucnv_close(conv); ``` -------------------------------- ### Get Case Map Code Point Start Index Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/ReplaceableContextIterator.java.html Retrieves the starting index of the code point currently being processed for case mapping. ```java public int getCaseMapCPStart() { return cpStart; } ``` -------------------------------- ### Initialize SCSU Window Usage Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.charset/CharsetSCSU.java.html Default configuration for dynamic window usage order. ```java static final byte initialWindowUse[] = {7, 0, 3, 2, 4, 5, 6, 1}; ``` -------------------------------- ### Rule Application State Examples Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/Transliterator.java.html Examples showing the cursor position during rule application. ```text |adefabcdefz ``` ```text a|defabcdefz ``` ```text ad|efabcdefz ``` -------------------------------- ### Get Installed Locales by Type in Java Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/ULocale.java.html Returns a list of all installed locales according to the specified type. Throws IllegalArgumentException if the type is null. ```java public static Collection getAvailableLocalesByType(AvailableType type) { if (type == null) { throw new IllegalArgumentException(); } List result; if (type == ULocale.AvailableType.WITH_LEGACY_ALIASES) { result = new ArrayList<>(); Collections.addAll( result, ICUResourceBundle.getAvailableULocales(ULocale.AvailableType.DEFAULT)); Collections.addAll( result, ICUResourceBundle.getAvailableULocales( ULocale.AvailableType.ONLY_LEGACY_ALIASES)); } else { result = Arrays.asList(ICUResourceBundle.getAvailableULocales(type)); } return result; } ``` -------------------------------- ### Example Tailoring with Options and Reordering Source: https://unicode-org.github.io/icu/userguide/collation/customization/index A tailoring example that reorders uppercase and lowercase and uses backwards-secondary ordering, demonstrating the use of options and custom character mappings. ```plaintext [caseFirst upper] [backwards 2] & C < č , Č & G < ģ , Ģ & I < y, Y & K < ķ , Ķ & L < ļ , Ļ & N < ņ , Ņ & S < š , Š & Z < ž , Ž ``` -------------------------------- ### Get Script Run Start Index Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.lang/UScriptRun.java.html Retrieves the starting index of the current script run. This method is deprecated and intended for internal ICU use only. ```APIDOC ## public final int getScriptStart() ### Description Gets the starting index of the current script run. ### Method `public final int getScriptStart()` ### Endpoint None ### Parameters None ### Request Example None ### Response #### Success Response (200) - **scriptStart** (int) - The index of the first character in the current script run. ### Response Example ```json { "scriptStart": 0 } ``` ### Deprecated This API is ICU internal only. ``` -------------------------------- ### Get Script Run Start Index Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.lang/UScriptRun.java.html Retrieves the starting index of the current script run. This method is deprecated and intended for internal ICU use. ```java public final int getScriptStart() { return scriptStart; } ``` -------------------------------- ### Normalization Sample Program Steps Source: https://unicode-org.github.io/icu/userguide/usefrom/cobol.html Outlines the steps for performing normalization checks and transformations on strings. ```text * The sample includes the following steps: * - Read a string from input file "ICU_NORM_Input.txt" * (file in ANSI format) * - Convert the string from code page into UTF-16 format * - Perform quick check on the string, to determine if the * string is in NFD (Canonical decomposition) * normalization format. * - Normalize the string into canonical composed form * (FCD and decomposed) * - Perform quick check on the result string, to determine * if the string is in NFD normalization form * - Convert the string from Unicode into the code page format * - Write the result to output file "ICU_NORM_Output.txt" * (file in ANSI format) * - Write debugging information to Display and * log file "ICU_NORM_Log.txt" (file in ANSI format) ** * The following ICU APIs are used: * ucnv_open * ucnv_toUChars * unorm_normalize * unorm_quickCheck * ucnv_fromUChars * ucnv_close ``` -------------------------------- ### Get Era Start Date Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/EraRules.java.html Retrieves the start date for a given era code. If the era code is not found or has no defined start date, an IllegalArgumentException is thrown. The date is returned as an array of [year, month, day]. ```java public int[] getStartDate(int eraCode, int[] fillIn) { int startDate = 0; if (eraCode >= minEra) { int startIdx = eraCode - minEra; if (startIdx < startDates.length) { startDate = startDates[startIdx]; } } if (isSet(startDate)) { return decodeDate(startDate, fillIn); } // We did not find the requested eraCode in our data throw new IllegalArgumentException("eraCode is not found in our data"); } ``` -------------------------------- ### ICUCurrencyDisplayInfoProvider Constructor Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/ICUCurrencyDisplayInfoProvider.java.html Initializes a new instance of the ICUCurrencyDisplayInfoProvider class. ```APIDOC ## ICUCurrencyDisplayInfoProvider() ### Description Initializes a new instance of the ICUCurrencyDisplayInfoProvider class. ### Method CONSTRUCTOR ### Endpoint N/A ### Parameters None ### Request Body None ### Response None ### Response Example None ``` -------------------------------- ### Configure ICU4C plug-ins Source: https://unicode-org.github.io/icu/userguide/icu4c/plug-ins.html Example of a configuration file entry for loading a specific library and entry point. ```text # this is icuplugins44.txt testplug.dll myPlugin hello=world ``` -------------------------------- ### Get Start Index of Input Text (Java) Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/Normalizer.java.html Retrieves the index of the start of the input text. Deprecated since ICU 2.2; use startIndex() instead. ```java public int getBeginIndex() { return 0; } ``` -------------------------------- ### Get Start of a Specific Range in UnicodeSet Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/UnicodeSet.java.html Retrieves the starting character of a specified range within the UnicodeSet. The index must be within the valid range of 0 to getRangeCount()-1. ```java public int getRangeStart(int index) { return list[index * 2]; } ``` -------------------------------- ### MessageFormat Usage Example Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/SelectFormat.java.html Demonstrates how to use MessageFormat with a select pattern in Java. ```java MessageFormat msgFmt = new MessageFormat("{0} est " + "{1, select, female {allée} other {allé}} à Paris.", new ULocale("fr")); Object args[] = {"Kirti","female"}; System.out.println(msgFmt.format(args)); ``` -------------------------------- ### Opening Resource Bundles (C API) Source: https://unicode-org.github.io/icu/userguide/locale/resources Demonstrates how to open a resource bundle using the C API `ures_open`. It explains the parameters for package, locale, and status, as well as potential informational/warning codes. ```APIDOC ## Opening of Resource Bundles (C API) ### Description Opens a resource bundle from a specified package and locale. ### Method `UResourceBundle* ures_open(const char* package, const char* locale, UErrorCode* status)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c UErrorCode status = U_ZERO_ERROR; UResourceBundle* icuRoot = ures_open(NULL, "root", &status); if (U_SUCCESS(status)) { /* everything is fine */ ... ures_close(icuRoot); } else { /* there was an error */ } ``` ### Response #### Success Response (200) `UResourceBundle*` - A pointer to the opened resource bundle. #### Response Example (See Request Example for context of success) ### Error Handling - `U_USING_FALLBACK_WARNING`: Requested bundle not found, a more general bundle was returned. - `U_USING_DEFAULT_WARNING`: No more general bundles found, default or root bundle returned (likely incorrect data). - Other `UErrorCode` values for general errors. ``` -------------------------------- ### Get Available Locales (ULocale objects) Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/Collator.java.html Returns an array of ULocale objects for which collators are installed, supporting RFC 3066. This list includes registered collators and those installed with ICU4J. ```java public static final ULocale[] getAvailableULocales() { if (shim == null) { return ICUResourceBundle.getAvailableULocales( ICUData.ICU_COLLATION_BASE_NAME, ICUResourceBundle.ICU_DATA_CLASS_LOADER); } return shim.getAvailableULocales(); } ``` -------------------------------- ### Get Year Length - Hebrew Calendar - Java Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/HebrewCalendar.java.html Calculates the total number of days in a given Hebrew year by finding the difference between the start of the next year and the start of the current year. ```java /** * Returns the number of days in the given Hebrew year * * @stable ICU 2.8 */ @Override protected int handleGetYearLength(int eyear) { return (int) (startOfYear(eyear + 1) - startOfYear(eyear)); } ``` -------------------------------- ### SelectFormat Constructor and Pattern Application Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/SelectFormat.java.html Demonstrates how to create a SelectFormat object with a given pattern and apply it. ```APIDOC ## SelectFormat Constructor and applyPattern ### Description Initializes a SelectFormat object with a specified pattern string and allows for applying or updating the pattern. ### Method `public SelectFormat(String pattern)` `public void applyPattern(String pattern)` ### Parameters #### Constructor Parameters - **pattern** (String) - The pattern for this SelectFormat. #### applyPattern Parameters - **pattern** (String) - The pattern for this select format. ### Request Example ```java // Constructor example SelectFormat selectFormat = new SelectFormat("{0} est {1, select, female {all\u00E9e} other {all\u00E9}} \u00E0 {2}.\n"); // applyPattern example MessagePattern msgPattern = new MessagePattern(); selectFormat.applyPattern("{0} {1, plural, one {est {2, select, female {all\u00E9e} other {all\u00E9}}} other {sont {2, select, female {all\u00E9es} other {all\u00E9s}}}} \u00E0 {3}.\n"); ``` ### Response #### Success Response (N/A for constructors and setters) N/A #### Response Example N/A ``` -------------------------------- ### Collation Sample Program Steps Source: https://unicode-org.github.io/icu/userguide/usefrom/cobol.html Outlines the steps for sorting and comparing strings using Unicode equivalence comparisons. ```text * The sample program includes the following steps: * - Read a string array from Input file "ICU_Coll_Input.txt" * (file in ANSI format) * - Convert string array from code page into UTF-16 format * - Compare the string array into the canonical composed * - Perform bubble sort of string array, according * to Unicode string equivalence comparisons * - Convert string array from Unicode into code page format * - Write the result to output file "ICU_Coll_Output.txt" * (file in ANSI format) * - Write debugging information to Display and * log file "ICU_Coll_Log.txt" (file in ANSI format) ** * The following ICU APIs are used: * ucol_open * ucol_strcoll * ucol_close * ucnv_open * ucnv_toUChars * ucnv_fromUChars * ucnv_close ``` -------------------------------- ### Two-Digit Year Handling Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/SimpleDateFormat.java.html Methods for setting and getting the start date for interpreting two-digit years. ```APIDOC ## POST /api/dates/2digit-year-start ### Description Sets the 100-year period into which two-digit years will be interpreted during date parsing. This helps in disambiguating years like '23' to either 1923 or 2023. ### Method POST ### Endpoint /api/dates/2digit-year-start ### Parameters #### Request Body - **startDate** (Date) - Required - The starting date of the 100-year window. Two-digit years will be parsed within the range [startDate, startDate + 100 years]. ### Request Example { "startDate": "1950-01-01T00:00:00Z" } ## GET /api/dates/2digit-year-start ### Description Retrieves the beginning date of the 100-year period used for interpreting two-digit years. ### Method GET ### Endpoint /api/dates/2digit-year-start ### Response #### Success Response (200) - **startDate** (Date) - The start date of the 100-year period. ### Response Example { "startDate": "1950-01-01T00:00:00Z" } ``` -------------------------------- ### Initialize Resource Bundle Keys Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/ResourceBundleWrapper.java.html Initializes a keys vector or logs a null return status based on the bundle state. ```java b.initKeysVector(); } else { if (DEBUG) System.out.println( "Returning null for " + baseName + "_" + localeID); } return b; } }); } } ``` -------------------------------- ### Get BidiRun Start Position Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/BidiRun.java.html Retrieves the first logical position of the run in the source text. ```java public int getStart() {         return start;     } ``` -------------------------------- ### Run Maven Package Source: https://unicode-org.github.io/icu/userguide/format_parse/messages/try-mf2.html Execute this command to build the project and run the tests. The output of the test will be displayed in the console. ```bash mvn package -q ``` -------------------------------- ### Get StringSegment Offset Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/StringSegment.java.html Retrieves the current starting offset of the StringSegment within the underlying String. ```java public int getOffset() { return start; } ``` -------------------------------- ### Get Available Locales By Type Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/ULocale.java.html Returns a list of all installed locales according to the specified type. ```APIDOC ## GET /getAvailableLocalesByType ### Description Returns a list of all installed locales according to the specified type. ### Method GET ### Endpoint /getAvailableLocalesByType ### Parameters #### Query Parameters - **type** (AvailableType) - Required - The type of locales to retrieve. Can be DEFAULT, WITH_LEGACY_ALIASES, ONLY_LEGACY_ALIASES, or STABLE. ### Request Example None ### Response #### Success Response (200) - **Collection** - A collection of ULocale objects matching the specified type. #### Response Example ```json [ { "locale": "en_US" }, { "locale": "en_GB" } ] ``` ``` -------------------------------- ### Resource Bundle Source File Example Source: https://unicode-org.github.io/icu/userguide/locale/resources An example of a resource bundle source file, demonstrating comments, locale definition, named resources, arrays, imported files, binary data, version info, integer arrays, and aliases. ```icu-resource-bundle // Comments start with a '//' and extend to the end of the line // first, a locale name for the bundle is defined. The whole bundle is a table // every resource, including the whole bundle has its name. // The name consists of invariant characters, digits and following symbols: -, _. root { menu { id { "mainmenu" } items { { id { "file" } name { "&File" } items { { id { "open" } name { "&Open" } } { id { "save" } name { "&Save" } } { id { "exit" } name { "&Exit" } } } } { id { "edit" } name { "&Edit" } items { { id { "copy" } name { "&Copy" } } { id { "cut" } name { "&Cut" } } { id { "paste" } name { "&Paste" } } } } ... } } // This resource is an array, thus accessible only through iteration and indexes... errors { "Invalid Command", "Bad Value", // Add more strings here... "Read the Manual" } splash:import { "splash_root.gif" } // This is a binary imported file pgpkey:bin { a1b2c3d4e5f67890 } // a binary value versionInfo { // a table major:int { 1 } // of integers minor:int { 4 } patch:int { 7 } } buttonSize:intvector { 10, 20, 10, 20 } // an array of 32-bit integers // will pick up data from zoneStrings resource in en bundle in the ICU package simpleAlias:alias { "/ICUDATA/en/zoneStrings" } // will pick up data from CollationElements resource in en bundle // in the ICU package CollationElements:alias { "/ICUDATA/en" } } ``` -------------------------------- ### Get Available Locales Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/ULocale.java.html Retrieves a list of all installed locales. This is equivalent to calling getAvailableLocalesByType with AvailableType.DEFAULT. ```APIDOC ## GET /getAvailableLocales ### Description Returns a list of all installed locales. This is equivalent to calling {@link #getAvailableLocalesByType} with AvailableType.DEFAULT. ### Method GET ### Endpoint /getAvailableLocales ### Parameters None ### Request Example None ### Response #### Success Response (200) - **ULocale[]** - An array of ULocale objects representing all installed locales. #### Response Example ```json [ { "locale": "en_US" }, { "locale": "fr_FR" } ] ``` ``` -------------------------------- ### Instantiate VersionInfo Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/VersionInfo.java.html Methods to create a VersionInfo instance from major and minor version components. ```java public static VersionInfo getInstance(int major, int minor) { return getInstance(major, minor, 0, 0); } ``` ```java public static VersionInfo getInstance(int major) { return getInstance(major, 0, 0, 0); } ``` -------------------------------- ### Get Next Start Time for Time Zone Rules Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/RuleBasedTimeZone.java.html Calculates the next start time for a time zone rule, considering historical data and DST savings. Used internally for rule processing. ```java finalRules[0].getNextStart( d1.getTime(), finalRules[1].getRawOffset(), finalRules[1].getDSTSavings(), false); historicTransitions.add( new TimeZoneTransition(d0.getTime(), finalRules[1], finalRules[0])); ``` -------------------------------- ### ICU4C .txt Resource Bundle Example Source: https://unicode-org.github.io/icu/userguide/locale/localizing.html This example demonstrates the structure of a .txt resource bundle file for ICU4C. It shows key-value pairs, nested structures, and how long strings can be split across lines. ```plaintext de { key1 { "Deutsche Sprache " "schwere Sprache" } key2 { "Düsseldorf" } } ``` -------------------------------- ### Java ULocale Component Example Source: https://unicode-org.github.io/icu/userguide/locale/index Demonstrates creating equivalent ULocale objects using a full ID string versus individual components. ```java ULocale ul = new Ulocale("sy_Cyrl_YU"); ULocale ul = new ULocale("sy", "Cyrl", "YU"); ``` -------------------------------- ### Get Available Locales (Locale objects) Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.text/Collator.java.html Returns an array of Locale objects for which collators are installed. This list includes registered collators and those installed with ICU4J. Note that Locale objects do not support RFC 3066. ```java public static Locale[] getAvailableLocales() { // TODO make this wrap getAvailableULocales later if (shim == null) { return ICUResourceBundle.getAvailableLocales( ICUData.ICU_COLLATION_BASE_NAME, ICUResourceBundle.ICU_DATA_CLASS_LOADER); } return shim.getAvailableLocales(); } ``` -------------------------------- ### Create a LayoutEngine instance Source: https://unicode-org.github.io/icu/userguide/layoutengine Use the LayoutEngineFactory to instantiate a LayoutEngine for specific font and script parameters. ```cpp LEFontInstace *font = ; UScriptCode script = ; LEErrorCode error = LE_NO_ERROR; LayoutEngine *engine; engine = LayoutEngine::layoutEngineFactory(font, script, 0, // language - ignored error); ``` -------------------------------- ### GET /trie2/range-end Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/Trie2_16.java.html Finds the last code point in a range that shares the same value as the starting code point. ```APIDOC ## GET /trie2/range-end ### Description Calculates the end of a range of code points that all share the same value, used for iterating over Trie2 contents. ### Method GET ### Parameters #### Query Parameters - **startingCP** (int) - Required - The code point to begin the search. - **limit** (int) - Required - The upper bound for the search. - **value** (int) - Required - The value to match against. ### Response #### Success Response (200) - **rangeEnd** (int) - The last code point with the same value as the starting code point. ``` -------------------------------- ### Configure ICU with runConfigureICU Source: https://unicode-org.github.io/icu/userguide/icu4c/build Run the `runConfigureICU` script to configure the build for your platform. Use `--help` for a list of options and supported platforms. ```bash ./runConfigureICU --help ``` -------------------------------- ### Get Current Index Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/UCharArrayIterator.java.html Returns the current iteration index relative to the start of the iterator's range. ```java public int getIndex() { return pos - start; } ``` -------------------------------- ### Implement a basic ICU4C plug-in Source: https://unicode-org.github.io/icu/userguide/icu4c/plug-ins.html A template for creating a plug-in entry point that handles query, load, and unload events. ```C U_CAPI UPlugTokenReturn U_EXPORT2 myPlugin (UPlugData *data, UPlugReason reason, UErrorCode *status) { if(reason==UPLUG_REASON_QUERY) { uplug_setPlugName(data, "Simple Plugin"); /* optional */ uplug_setPlugLevel(data, UPLUG_LEVEL_HIGH); /* Mandatory */ } else if(reason==UPLUG_REASON_LOAD) { /* ... load ... */ /* Set up some ICU things here. */ } else if(reason==UPLUG_REASON_UNLOAD) { /* ... unload ... */ } return UPLUG_TOKEN; /* Mandatory. */ } ``` -------------------------------- ### Get StringSegment Length Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/StringSegment.java.html Returns the current length of the StringSegment, calculated as the difference between the end and start offsets. ```java public int length() { return end - start; } ``` -------------------------------- ### Opening Resource Bundles (C++ API) Source: https://unicode-org.github.io/icu/userguide/locale/resources Illustrates opening a resource bundle using the C++ constructor. It highlights the use of `UnicodeString` for package and `Locale` object for locale. ```APIDOC ## Opening of Resource Bundles (C++ API) ### Description Opens a resource bundle using its C++ constructor. ### Method `ResourceBundle(const UnicodeString& package, const Locale& locale, UErrorCode& status)` or `ResourceBundle(const char* packageName, const char* localeName, UErrorCode& status)` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp UErrorCode status = U_ZERO_ERROR; // Relying on automatic construction of Locale object from a char* ResourceBundle myResource("myPackage", "de_AT", status); if (U_SUCCESS(status)) { /* everything is fine */ ... /* bundle is closed automatically when going out of scope */ } else { /* there was an error */ } ``` ### Response #### Success Response (200) `ResourceBundle` object - An instance of the opened resource bundle. #### Response Example (See Request Example for context of success) ### Error Handling - `UErrorCode` will indicate success or failure, similar to C API warnings. ``` -------------------------------- ### GET /rbbidata/row-index Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.impl/RBBIDataWrapper.java.html Calculates the array index of the start of a state table row for a given state number. ```APIDOC ## GET /rbbidata/row-index ### Description Computes the starting index of a specific state row within the state table based on the character category count. ### Method GET ### Endpoint /rbbidata/row-index ### Parameters #### Query Parameters - **state** (int) - Required - The state number to look up. ### Response #### Success Response (200) - **index** (int) - The calculated array index. ``` -------------------------------- ### Get Available Locales Source: https://unicode-org.github.io/icu/userguide/dev/reports/icu4j_coverage/html/com.ibm.icu.util/Calendar.java.html Retrieves a list of locales for which Calendars are installed. This method is available from ICU 2.0. ```java public static Locale[] getAvailableLocales() { // TODO return ICUResourceBundle.getAvailableLocales(); } ```