diff options
Diffstat (limited to 'Build/source/libs/icu/icu-50.1/samples/translit')
16 files changed, 1270 insertions, 0 deletions
diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/Makefile b/Build/source/libs/icu/icu-50.1/samples/translit/Makefile new file mode 100644 index 00000000000..d7d2baf97e1 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/Makefile @@ -0,0 +1,22 @@ +# Copyright (c) 2000-2003 IBM, Inc. and others +# sample code makefile + +# Usage: +# - configure, build, install ICU (make install) +# - make sure "icu-config" (in the ICU installed bin directory) is on +# the path +# - do 'make' in this directory + +#### definitions +# Name of your target +TARGET=translit + +# All object files (C or C++) +OBJECTS=main.o unaccent.o util.o + +#### rules +# Load in standard makefile definitions +include ../defs.mk + +# the actual rules (this is a simple sample) +include ../rules.mk diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/README.TXT b/Build/source/libs/icu/icu-50.1/samples/translit/README.TXT new file mode 100644 index 00000000000..1c77ca8c8ac --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/README.TXT @@ -0,0 +1,109 @@ +Copyright (c) 2002-2010, International Business Machines Corporation and others. All Rights Reserved. + + +IMPORTANT: + +This sample was originally intended as an exercise for the ICU Workshop (September 2000). +The code currently provided in the solution file is the answer to the exercises, each step can still be found in the 'answers' subdirectory. + + + + http://www.icu-project.org/docs/workshop_2000/agenda.html + + Day 2: September 12th 2000 + Pre-requisite: + 1. All the hardware and software requirements from Day 1. + 2. Attended or fully understand Day 1 material. + 3. Read through the ICU user's guide at + http://www.icu-project.org/userguide/. + + #Transformation Support + 10:45am - 12:00pm + Alan Liu + + Topics: + 1. What is the Unicode normalization? + 2. What kind of case mapping support is available in ICU? + 3. What is Transliteration and how do I use a Transliterator on a document? + 4. How do I add my own Transliterator? + + +INSTRUCTIONS +------------ + +This exercise was developed and tested on ICU release 1.6.0, Win32, +Microsoft Visual C++ 6.0. It should work on other ICU releases and +other platforms as well. + + MSVC: + Open the file "translit.sln" in Microsoft Visual C++. + + Unix: + - Build and install ICU with a prefix, for example '--prefix=/home/srl/ICU' + - Set the variable ICU_PREFIX=/home/srl/ICU and use GNU make in + this directory. + - You may use 'make check' to invoke this sample. + + +PROBLEMS +-------- + +Problem 0: + + To start with, the program prints out a series of dates formatted in + Greek. Set up the program, build it, and run it. + +Problem 1: Basic Transliterator (Easy) + + The Greek text shows up almost entirely as Unicode escapes. These + are unreadable on a US machine. Use an existing system + transliterator to transliterate the Greek text to Latin so it can be + phonetically read on a US machine. If you don't know the names of + the system transliterators, use Transliterator::getAvailableID() and + Transliterator::countAvailableIDs(), or look directly in the index + table icu/data/translit_index.txt. + +Problem 2: RuleBasedTransliterator (Medium) + + Some of the text is still unreadable and shows up as Unicode escape + sequences. Create a RuleBasedTransliterator to change the + unreadable characters to close ASCII equivalents. For example, the + rule "\u00C0 > A;" will change an 'A' with a grave accent to a plain + 'A'. + + To save typing, use UnicodeSets to handle ranges of characters. + + See the included file "U0080.pdf" for a table of the U+00C0 to U+00FF + Unicode block. + +Problem 3: Transliterator subclassing; Normalizer (Difficult) + + The rule-based approach is flexible and, in most cases, the best + choice for creating a new transliterator. Sometimes, however, a + more elegant algorithmic solution is available. Instead of typing + in a list of rules, you can write C++ code to accomplish the desired + transliteration. + + Use a Normalizer to remove accents from characters. You will need + to convert each character to a sequence of base and combining + characters by applying a canonical denormalization transformation. + Then discard the combining characters (the accents etc.) leaving the + base character. Wrap this all up in a subclass of the + Transliterator class that overrides the pure virtual + handleTransliterate() method. + + +ANSWERS +------- + +The exercise includes answers. These are in the "answers" directory, +and are numbered 1, 2, etc. In some cases new files that the user +needs to create are included in the answers directory. + +If you get stuck and you want to move to the next step, copy the +answers file into the main directory in order to proceed. E.g., +"main_1.cpp" contains the original "main.cpp" file. "main_2.cpp" +contains the "main.cpp" file after problem 1. Etc. + + +Have fun! diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_1.cpp b/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_1.cpp new file mode 100644 index 00000000000..ba526eb675b --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_1.cpp @@ -0,0 +1,70 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/rbt.h" +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" +#include "unaccent.h" + +int main(int argc, char **argv) { + + Calendar *cal; + DateFormat *fmt; + DateFormat *defFmt; + UErrorCode status = U_ZERO_ERROR; + Locale greece("el", "GR"); + UnicodeString str, str2; + + // Create a calendar in the Greek locale + cal = Calendar::createInstance(greece, status); + check(status, "Calendar::createInstance"); + + // Create a formatter + fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); + fmt->setCalendar(*cal); + + // Create a default formatter + defFmt = DateFormat::createDateInstance(DateFormat::kFull); + defFmt->setCalendar(*cal); + + // Loop over various months + for (int32_t month = Calendar::JANUARY; + month <= Calendar::DECEMBER; + ++month) { + + // Set the calendar to a date + cal->clear(); + cal->set(1999, month, 4); + + // Format the date in default locale + str.remove(); + defFmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Date: "); + uprintf(escape(str)); + printf("\n"); + + // Format the date for Greece + str.remove(); + fmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Greek formatted date: "); + uprintf(escape(str)); + printf("\n\n"); + } + + // Clean up + delete fmt; + delete cal; + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_2.cpp b/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_2.cpp new file mode 100644 index 00000000000..bf392d105a6 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_2.cpp @@ -0,0 +1,85 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/rbt.h" +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" +#include "unaccent.h" + +int main(int argc, char **argv) { + + Calendar *cal; + DateFormat *fmt; + DateFormat *defFmt; + Transliterator *greek_latin; + UErrorCode status = U_ZERO_ERROR; + Locale greece("el", "GR"); + UnicodeString str, str2; + + // Create a calendar in the Greek locale + cal = Calendar::createInstance(greece, status); + check(status, "Calendar::createInstance"); + + // Create a formatter + fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); + fmt->setCalendar(*cal); + + // Create a default formatter + defFmt = DateFormat::createDateInstance(DateFormat::kFull); + defFmt->setCalendar(*cal); + + // Create a Greek-Latin Transliterator + greek_latin = Transliterator::createInstance("Greek-Latin"); + if (greek_latin == 0) { + printf("ERROR: Transliterator::createInstance() failed\n"); + exit(1); + } + + // Loop over various months + for (int32_t month = Calendar::JANUARY; + month <= Calendar::DECEMBER; + ++month) { + + // Set the calendar to a date + cal->clear(); + cal->set(1999, month, 4); + + // Format the date in default locale + str.remove(); + defFmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Date: "); + uprintf(escape(str)); + printf("\n"); + + // Format the date for Greece + str.remove(); + fmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Greek formatted date: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + greek_latin->transliterate(str); + printf("Transliterated via Greek-Latin: "); + uprintf(escape(str)); + printf("\n\n"); + } + + // Clean up + delete fmt; + delete cal; + delete greek_latin; + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_3.cpp b/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_3.cpp new file mode 100644 index 00000000000..93065a252a0 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_3.cpp @@ -0,0 +1,112 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/rbt.h" +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" +#include "unaccent.h" + +// RuleBasedTransliterator rules to remove accents from characters +// so they can be displayed as ASCIIx +UnicodeString UNACCENT_RULES( + "[\\u00C0-\\u00C5] > A;" + "[\\u00C8-\\u00CB] > E;" + "[\\u00CC-\\u00CF] > I;" + "[\\u00E0-\\u00E5] > a;" + "[\\u00E8-\\u00EB] > e;" + "[\\u00EC-\\u00EF] > i;" + ); + +int main(int argc, char **argv) { + + Calendar *cal; + DateFormat *fmt; + DateFormat *defFmt; + Transliterator *greek_latin; + Transliterator *rbtUnaccent; + UErrorCode status = U_ZERO_ERROR; + Locale greece("el", "GR"); + UnicodeString str, str2; + + // Create a calendar in the Greek locale + cal = Calendar::createInstance(greece, status); + check(status, "Calendar::createInstance"); + + // Create a formatter + fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); + fmt->setCalendar(*cal); + + // Create a default formatter + defFmt = DateFormat::createDateInstance(DateFormat::kFull); + defFmt->setCalendar(*cal); + + // Create a Greek-Latin Transliterator + greek_latin = Transliterator::createInstance("Greek-Latin"); + if (greek_latin == 0) { + printf("ERROR: Transliterator::createInstance() failed\n"); + exit(1); + } + + // Create a custom Transliterator + rbtUnaccent = new RuleBasedTransliterator("RBTUnaccent", + UNACCENT_RULES, + UTRANS_FORWARD, + status); + check(status, "RuleBasedTransliterator::ct"); + + // Loop over various months + for (int32_t month = Calendar::JANUARY; + month <= Calendar::DECEMBER; + ++month) { + + // Set the calendar to a date + cal->clear(); + cal->set(1999, month, 4); + + // Format the date in default locale + str.remove(); + defFmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Date: "); + uprintf(escape(str)); + printf("\n"); + + // Format the date for Greece + str.remove(); + fmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Greek formatted date: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + greek_latin->transliterate(str); + printf("Transliterated via Greek-Latin: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + str2 = str; + rbtUnaccent->transliterate(str); + printf("Transliterated via RBT unaccent: "); + uprintf(escape(str)); + printf("\n\n"); + } + + // Clean up + delete fmt; + delete cal; + delete greek_latin; + delete rbtUnaccent; + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_4.cpp b/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_4.cpp new file mode 100644 index 00000000000..5b51cb5672c --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/answers/main_4.cpp @@ -0,0 +1,122 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/rbt.h" +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" +#include "unaccent.h" + +// RuleBasedTransliterator rules to remove accents from characters +// so they can be displayed as ASCIIx +UnicodeString UNACCENT_RULES( + "[\\u00C0-\\u00C5] > A;" + "[\\u00C8-\\u00CB] > E;" + "[\\u00CC-\\u00CF] > I;" + "[\\u00E0-\\u00E5] > a;" + "[\\u00E8-\\u00EB] > e;" + "[\\u00EC-\\u00EF] > i;" + ); + +int main(int argc, char **argv) { + + Calendar *cal; + DateFormat *fmt; + DateFormat *defFmt; + Transliterator *greek_latin; + Transliterator *rbtUnaccent; + Transliterator *unaccent; + UErrorCode status = U_ZERO_ERROR; + Locale greece("el", "GR"); + UnicodeString str, str2; + + // Create a calendar in the Greek locale + cal = Calendar::createInstance(greece, status); + check(status, "Calendar::createInstance"); + + // Create a formatter + fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); + fmt->setCalendar(*cal); + + // Create a default formatter + defFmt = DateFormat::createDateInstance(DateFormat::kFull); + defFmt->setCalendar(*cal); + + // Create a Greek-Latin Transliterator + greek_latin = Transliterator::createInstance("Greek-Latin"); + if (greek_latin == 0) { + printf("ERROR: Transliterator::createInstance() failed\n"); + exit(1); + } + + // Create a custom Transliterator + rbtUnaccent = new RuleBasedTransliterator("RBTUnaccent", + UNACCENT_RULES, + UTRANS_FORWARD, + status); + check(status, "RuleBasedTransliterator::ct"); + + // Create a custom Transliterator + unaccent = new UnaccentTransliterator(); + + // Loop over various months + for (int32_t month = Calendar::JANUARY; + month <= Calendar::DECEMBER; + ++month) { + + // Set the calendar to a date + cal->clear(); + cal->set(1999, month, 4); + + // Format the date in default locale + str.remove(); + defFmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Date: "); + uprintf(escape(str)); + printf("\n"); + + // Format the date for Greece + str.remove(); + fmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Greek formatted date: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + greek_latin->transliterate(str); + printf("Transliterated via Greek-Latin: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + str2 = str; + rbtUnaccent->transliterate(str); + printf("Transliterated via RBT unaccent: "); + uprintf(escape(str)); + printf("\n"); + + unaccent->transliterate(str2); + printf("Transliterated via normalizer unaccent: "); + uprintf(escape(str2)); + printf("\n\n"); + } + + // Clean up + delete fmt; + delete cal; + delete greek_latin; + delete unaccent; + delete rbtUnaccent; + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/answers/unaccent.cpp b/Build/source/libs/icu/icu-50.1/samples/translit/answers/unaccent.cpp new file mode 100644 index 00000000000..8b9832d79b6 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/answers/unaccent.cpp @@ -0,0 +1,54 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unaccent.h" + +/** + * Constructor + */ +UnaccentTransliterator::UnaccentTransliterator() : + normalizer("", Normalizer::DECOMP), + Transliterator("Unaccent", 0) { +} + +/** + * Destructor + */ +UnaccentTransliterator::~UnaccentTransliterator() { +} + +/** + * Remove accents from a character using Normalizer. + */ +UChar UnaccentTransliterator::unaccent(UChar c) const { + UnicodeString str(c); + UErrorCode status = U_ZERO_ERROR; + UnaccentTransliterator* t = (UnaccentTransliterator*)this; + + t->normalizer.setText(str, status); + if (U_FAILURE(status)) { + return c; + } + return (UChar) t->normalizer.next(); +} + +/** + * Implement Transliterator API + */ +void UnaccentTransliterator::handleTransliterate(Replaceable& text, + UTransPosition& index, + UBool incremental) const { + UnicodeString str("a"); + while (index.start < index.limit) { + UChar c = text.charAt(index.start); + UChar d = unaccent(c); + if (c != d) { + str.setCharAt(0, d); + text.handleReplaceBetween(index.start, index.start+1, str); + } + index.start++; + } +} diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/answers/unaccent.h b/Build/source/libs/icu/icu-50.1/samples/translit/answers/unaccent.h new file mode 100644 index 00000000000..4cda092d58f --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/answers/unaccent.h @@ -0,0 +1,41 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/normlzr.h" + +class UnaccentTransliterator : public Transliterator { + + public: + + /** + * Constructor + */ + UnaccentTransliterator(); + + /** + * Destructor + */ + virtual ~UnaccentTransliterator(); + + protected: + + /** + * Implement Transliterator API + */ + virtual void handleTransliterate(Replaceable& text, + UTransPosition& index, + UBool incremental) const; + + private: + + /** + * Unaccent a single character using normalizer. + */ + UChar unaccent(UChar c) const; + + Normalizer normalizer; +}; diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/main.cpp b/Build/source/libs/icu/icu-50.1/samples/translit/main.cpp new file mode 100644 index 00000000000..5bf46717ff1 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/main.cpp @@ -0,0 +1,124 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +//#include "unicode/rbt.h" +#include "unicode/unistr.h" +#include "unicode/calendar.h" +#include "unicode/datefmt.h" +#include <stdio.h> +#include <stdlib.h> +#include "util.h" +#include "unaccent.h" + +// RuleBasedTransliterator rules to remove accents from characters +// so they can be displayed as ASCIIx +UnicodeString UNACCENT_RULES( + "[\\u00C0-\\u00C5] > A;" + "[\\u00C8-\\u00CB] > E;" + "[\\u00CC-\\u00CF] > I;" + "[\\u00E0-\\u00E5] > a;" + "[\\u00E8-\\u00EB] > e;" + "[\\u00EC-\\u00EF] > i;" + ); + +int main(int argc, char **argv) { + + Calendar *cal; + DateFormat *fmt; + DateFormat *defFmt; + Transliterator *greek_latin; + Transliterator *rbtUnaccent; + Transliterator *unaccent; + UParseError pError; + UErrorCode status = U_ZERO_ERROR; + Locale greece("el", "GR"); + UnicodeString str, str2; + + // Create a calendar in the Greek locale + cal = Calendar::createInstance(greece, status); + check(status, "Calendar::createInstance"); + + // Create a formatter + fmt = DateFormat::createDateInstance(DateFormat::kFull, greece); + fmt->setCalendar(*cal); + + // Create a default formatter + defFmt = DateFormat::createDateInstance(DateFormat::kFull); + defFmt->setCalendar(*cal); + + // Create a Greek-Latin Transliterator + greek_latin = Transliterator::createInstance("Greek-Latin", UTRANS_FORWARD, status); + if (greek_latin == 0) { + printf("ERROR: Transliterator::createInstance() failed\n"); + exit(1); + } + + // Create a custom Transliterator + rbtUnaccent = Transliterator::createFromRules("RBTUnaccent", + UNACCENT_RULES, + UTRANS_FORWARD, + pError, + status); + check(status, "Transliterator::createFromRules"); + + // Create a custom Transliterator + unaccent = new UnaccentTransliterator(); + + // Loop over various months + for (int32_t month = Calendar::JANUARY; + month <= Calendar::DECEMBER; + ++month) { + + // Set the calendar to a date + cal->clear(); + cal->set(1999, month, 4); + + // Format the date in default locale + str.remove(); + defFmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Date: "); + uprintf(escape(str)); + printf("\n"); + + // Format the date for Greece + str.remove(); + fmt->format(cal->getTime(status), str, status); + check(status, "DateFormat::format"); + printf("Greek formatted date: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + greek_latin->transliterate(str); + printf("Transliterated via Greek-Latin: "); + uprintf(escape(str)); + printf("\n"); + + // Transliterate result + str2 = str; + rbtUnaccent->transliterate(str); + printf("Transliterated via RBT unaccent: "); + uprintf(escape(str)); + printf("\n"); + + unaccent->transliterate(str2); + printf("Transliterated via normalizer unaccent: "); + uprintf(escape(str2)); + printf("\n\n"); + } + + // Clean up + delete fmt; + delete cal; + delete greek_latin; + delete unaccent; + delete rbtUnaccent; + + printf("Exiting successfully\n"); + return 0; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/translit.sln b/Build/source/libs/icu/icu-50.1/samples/translit/translit.sln new file mode 100644 index 00000000000..6b74f1b5fce --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/translit.sln @@ -0,0 +1,25 @@ +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual Studio 2010 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "translit", "translit.vcxproj", "{D1BEC124-303A-4F44-BA70-55769B8FE96A}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|Win32.ActiveCfg = Debug|Win32 + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|Win32.Build.0 = Debug|Win32 + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|x64.ActiveCfg = Debug|Win32 + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Debug|x64.Build.0 = Debug|Win32 + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|Win32.ActiveCfg = Release|Win32 + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|Win32.Build.0 = Release|Win32 + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|x64.ActiveCfg = Release|Win32 + {D1BEC124-303A-4F44-BA70-55769B8FE96A}.Release|x64.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/translit.vcxproj b/Build/source/libs/icu/icu-50.1/samples/translit/translit.vcxproj new file mode 100644 index 00000000000..4f23fbebd15 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/translit.vcxproj @@ -0,0 +1,249 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup Label="ProjectConfigurations"> + <ProjectConfiguration Include="Debug|Win32"> + <Configuration>Debug</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Debug|x64"> + <Configuration>Debug</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|Win32"> + <Configuration>Release</Configuration> + <Platform>Win32</Platform> + </ProjectConfiguration> + <ProjectConfiguration Include="Release|x64"> + <Configuration>Release</Configuration> + <Platform>x64</Platform> + </ProjectConfiguration> + </ItemGroup> + <PropertyGroup Label="Globals"> + <ProjectGuid>{D1BEC124-303A-4F44-BA70-55769B8FE96A}</ProjectGuid> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> + <ConfigurationType>Application</ConfigurationType> + <UseOfMfc>false</UseOfMfc> + <CharacterSet>MultiByte</CharacterSet> + </PropertyGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> + <ImportGroup Label="ExtensionSettings"> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets"> + <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> + <Import Project="$(VCTargetsPath)Microsoft.CPP.UpgradeFromVC71.props" /> + </ImportGroup> + <PropertyGroup Label="UserMacros" /> + <PropertyGroup> + <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">.\x86\Debug\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">.\x64\Debug\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\x86\Release\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental> + <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</OutDir> + <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\x64\Release\</IntDir> + <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental> + </PropertyGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> + <Midl> + <TypeLibraryName>.\x86\Debug/translit.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> + <PrecompiledHeader> + </PrecompiledHeader> + <PrecompiledHeaderOutputFile>.\x86\Debug/translit.pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\x86\Debug/</AssemblerListingLocation> + <ObjectFileName>.\x86\Debug/</ObjectFileName> + <ProgramDataBaseFileName>.\x86\Debug/</ProgramDataBaseFileName> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>EditAndContinue</DebugInformationFormat> + <CompileAs>Default</CompileAs> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>.\x86\Debug/translit.exe</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>.\x86\Debug/translit.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + <TypeLibraryName>.\x64\Debug/translit.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <Optimization>Disabled</Optimization> + <AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN64;WIN32;_DEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks> + <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> + <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> + <PrecompiledHeader> + </PrecompiledHeader> + <PrecompiledHeaderOutputFile>.\x64\Debug/translit.pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\x64\Debug/</AssemblerListingLocation> + <ObjectFileName>.\x64\Debug/</ObjectFileName> + <ProgramDataBaseFileName>.\x64\Debug/</ProgramDataBaseFileName> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> + <CompileAs>Default</CompileAs> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>icuucd.lib;icuind.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>.\x64\Debug/translit.exe</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <GenerateDebugInformation>true</GenerateDebugInformation> + <ProgramDatabaseFile>.\x64\Debug/translit.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <TargetMachine>MachineX64</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> + <Midl> + <TypeLibraryName>.\x86\Release/translit.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> + <PrecompiledHeader> + </PrecompiledHeader> + <PrecompiledHeaderOutputFile>.\x86\Release/translit.pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\x86\Release/</AssemblerListingLocation> + <ObjectFileName>.\x86\Release/</ObjectFileName> + <ProgramDataBaseFileName>.\x86\Release/</ProgramDataBaseFileName> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <CompileAs>Default</CompileAs> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>.\x86\Release/translit.exe</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <AdditionalLibraryDirectories>..\..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <ProgramDatabaseFile>.\x86\Release/translit.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + </Link> + </ItemDefinitionGroup> + <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> + <Midl> + <TargetEnvironment>X64</TargetEnvironment> + <TypeLibraryName>.\x64\Release/translit.tlb</TypeLibraryName> + </Midl> + <ClCompile> + <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> + <AdditionalIncludeDirectories>..\..\..\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> + <PreprocessorDefinitions>WIN64;WIN32;NDEBUG;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <StringPooling>true</StringPooling> + <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> + <FunctionLevelLinking>true</FunctionLevelLinking> + <TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType> + <PrecompiledHeader> + </PrecompiledHeader> + <PrecompiledHeaderOutputFile>.\x64\Release/translit.pch</PrecompiledHeaderOutputFile> + <AssemblerListingLocation>.\x64\Release/</AssemblerListingLocation> + <ObjectFileName>.\x64\Release/</ObjectFileName> + <ProgramDataBaseFileName>.\x64\Release/</ProgramDataBaseFileName> + <WarningLevel>Level3</WarningLevel> + <SuppressStartupBanner>true</SuppressStartupBanner> + <CompileAs>Default</CompileAs> + </ClCompile> + <ResourceCompile> + <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions> + <Culture>0x0409</Culture> + </ResourceCompile> + <Link> + <AdditionalDependencies>icuuc.lib;icuin.lib;%(AdditionalDependencies)</AdditionalDependencies> + <OutputFile>.\x64\Release/translit.exe</OutputFile> + <SuppressStartupBanner>true</SuppressStartupBanner> + <AdditionalLibraryDirectories>..\..\..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> + <ProgramDatabaseFile>.\x64\Release/translit.pdb</ProgramDatabaseFile> + <SubSystem>Console</SubSystem> + <RandomizedBaseAddress>false</RandomizedBaseAddress> + <DataExecutionPrevention> + </DataExecutionPrevention> + <TargetMachine>MachineX64</TargetMachine> + </Link> + </ItemDefinitionGroup> + <ItemGroup> + <ClCompile Include="main.cpp" /> + <ClCompile Include="unaccent.cpp" /> + <ClCompile Include="util.cpp" /> + </ItemGroup> + <ItemGroup> + <ClInclude Include="unaccent.h" /> + </ItemGroup> + <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> + <ImportGroup Label="ExtensionTargets"> + </ImportGroup> +</Project> diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/translit.vcxproj.filters b/Build/source/libs/icu/icu-50.1/samples/translit/translit.vcxproj.filters new file mode 100644 index 00000000000..51eb1c46aa6 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/translit.vcxproj.filters @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <ItemGroup> + <Filter Include="Source Files"> + <UniqueIdentifier>{54b54bed-3b7b-4c0c-88b9-c7d168eb2b2f}</UniqueIdentifier> + <Extensions>cpp;c;cxx;rc;def;r;odl;idl;hpj;bat</Extensions> + </Filter> + <Filter Include="Header Files"> + <UniqueIdentifier>{1b482e95-f708-45c1-afa7-842defddd5ab}</UniqueIdentifier> + <Extensions>h;hpp;hxx;hm;inl</Extensions> + </Filter> + <Filter Include="Resource Files"> + <UniqueIdentifier>{33d7c053-4ff7-4f22-974c-5c36cf13b8f6}</UniqueIdentifier> + <Extensions>ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe</Extensions> + </Filter> + </ItemGroup> + <ItemGroup> + <ClCompile Include="main.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="unaccent.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + <ClCompile Include="util.cpp"> + <Filter>Source Files</Filter> + </ClCompile> + </ItemGroup> + <ItemGroup> + <ClInclude Include="unaccent.h"> + <Filter>Header Files</Filter> + </ClInclude> + </ItemGroup> +</Project>
\ No newline at end of file diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/unaccent.cpp b/Build/source/libs/icu/icu-50.1/samples/translit/unaccent.cpp new file mode 100644 index 00000000000..d3af7f35df7 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/unaccent.cpp @@ -0,0 +1,56 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unaccent.h" + +const char UnaccentTransliterator::fgClassID = 0; + +/** + * Constructor + */ +UnaccentTransliterator::UnaccentTransliterator() : + normalizer("", UNORM_NFD), + Transliterator("Unaccent", 0) { +} + +/** + * Destructor + */ +UnaccentTransliterator::~UnaccentTransliterator() { +} + +/** + * Remove accents from a character using Normalizer. + */ +UChar UnaccentTransliterator::unaccent(UChar c) const { + UnicodeString str(c); + UErrorCode status = U_ZERO_ERROR; + UnaccentTransliterator* t = (UnaccentTransliterator*)this; + + t->normalizer.setText(str, status); + if (U_FAILURE(status)) { + return c; + } + return (UChar) t->normalizer.next(); +} + +/** + * Implement Transliterator API + */ +void UnaccentTransliterator::handleTransliterate(Replaceable& text, + UTransPosition& index, + UBool incremental) const { + UnicodeString str("a"); + while (index.start < index.limit) { + UChar c = text.charAt(index.start); + UChar d = unaccent(c); + if (c != d) { + str.setCharAt(0, d); + text.handleReplaceBetween(index.start, index.start+1, str); + } + index.start++; + } +} diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/unaccent.h b/Build/source/libs/icu/icu-50.1/samples/translit/unaccent.h new file mode 100644 index 00000000000..10ee9d9096b --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/unaccent.h @@ -0,0 +1,89 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2003, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/translit.h" +#include "unicode/normlzr.h" + +class UnaccentTransliterator : public Transliterator { + + public: + + /** + * Constructor + */ + UnaccentTransliterator(); + + /** + * Destructor + */ + virtual ~UnaccentTransliterator(); + + protected: + + /** + * Implement Transliterator API + */ + virtual void handleTransliterate(Replaceable& text, + UTransPosition& index, + UBool incremental) const; + + private: + + /** + * Unaccent a single character using normalizer. + */ + UChar unaccent(UChar c) const; + + Normalizer normalizer; + +public: + + /** + * Return the class ID for this class. This is useful only for + * comparing to a return value from getDynamicClassID(). For example: + * <pre> + * . Base* polymorphic_pointer = createPolymorphicObject(); + * . if (polymorphic_pointer->getDynamicClassID() == + * . Derived::getStaticClassID()) ... + * </pre> + * @return The class ID for all objects of this class. + * @stable ICU 2.0 + */ + static inline UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }; + + /** + * Returns a unique class ID <b>polymorphically</b>. This method + * is to implement a simple version of RTTI, since not all C++ + * compilers support genuine RTTI. Polymorphic operator==() and + * clone() methods call this method. + * + * <p>Concrete subclasses of Transliterator that wish clients to + * be able to identify them should implement getDynamicClassID() + * and also a static method and data member: + * + * <pre> + * static UClassID getStaticClassID() { return (UClassID)&fgClassID; } + * static char fgClassID; + * </pre> + * + * Subclasses that do not implement this method will have a + * dynamic class ID of Transliterator::getStatisClassID(). + * + * @return The class ID for this object. All objects of a given + * class have the same class ID. Objects of other classes have + * different class IDs. + * @stable ICU 2.0 + */ + virtual UClassID getDynamicClassID(void) const { return getStaticClassID(); }; + +private: + + /** + * Class identifier for subclasses of Transliterator that do not + * define their class (anonymous subclasses). + */ + static const char fgClassID; +}; diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/util.cpp b/Build/source/libs/icu/icu-50.1/samples/translit/util.cpp new file mode 100644 index 00000000000..9f0013c3b46 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/util.cpp @@ -0,0 +1,63 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2010, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" +#include <stdio.h> +#include <stdlib.h> + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg) { + if (U_FAILURE(status)) { + printf("ERROR: %s (%s)\n", u_errorName(status), msg); + exit(1); + } + // printf("Ok: %s\n", msg); +} + +// Append a hex string to the target +static UnicodeString& appendHex(uint32_t number, + int8_t digits, + UnicodeString& target) { + static const UnicodeString DIGIT_STRING("0123456789ABCDEF"); + while (digits > 0) { + target += DIGIT_STRING[(number >> ((--digits) * 4)) & 0xF]; + } + return target; +} + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source) { + int32_t i; + UnicodeString target; + target += "\""; + for (i=0; i<source.length(); ++i) { + UChar ch = source[i]; + if (ch < 0x09 || (ch > 0x0A && ch < 0x20) || ch > 0x7E) { + target += "\\u"; + appendHex(ch, 4, target); + } else { + target += ch; + } + } + target += "\""; + return target; +} + +// Print the given string to stdout +void uprintf(const UnicodeString &str) { + char *buf = 0; + int32_t len = str.length(); + // int32_t bufLen = str.extract(0, len, buf); // Preflight + /* Preflighting seems to be broken now, so assume 1-1 conversion, + plus some slop. */ + int32_t bufLen = len + 16; + int32_t actualLen; + buf = new char[bufLen + 1]; + actualLen = str.extract(0, len, buf/*, bufLen*/); // Default codepage conversion + buf[actualLen] = 0; + printf("%s", buf); + delete [] buf; +} diff --git a/Build/source/libs/icu/icu-50.1/samples/translit/util.h b/Build/source/libs/icu/icu-50.1/samples/translit/util.h new file mode 100644 index 00000000000..2d9c4c724e2 --- /dev/null +++ b/Build/source/libs/icu/icu-50.1/samples/translit/util.h @@ -0,0 +1,16 @@ +/******************************************************************** + * COPYRIGHT: + * Copyright (c) 1999-2002, International Business Machines Corporation and + * others. All Rights Reserved. + ********************************************************************/ + +#include "unicode/unistr.h" + +// Verify that a UErrorCode is successful; exit(1) if not +void check(UErrorCode& status, const char* msg); + +// Replace nonprintable characters with unicode escapes +UnicodeString escape(const UnicodeString &source); + +// Print the given string to stdout +void uprintf(const UnicodeString &str); |