ICU-22691 Make sample code possible to compile with current ICU4C.

This commit is contained in:
Fredrik Roubert 2024-03-19 17:11:20 +01:00 committed by Fredrik Roubert
parent dd7b0a9d6d
commit 142850ae2c
6 changed files with 17 additions and 8 deletions

View file

@ -9,7 +9,6 @@
***********************************************************************/
#include "unicode/translit.h"
#include "unicode/rbt.h"
#include "unicode/unistr.h"
#include "unicode/calendar.h"
#include "unicode/datefmt.h"

View file

@ -9,7 +9,6 @@
***********************************************************************/
#include "unicode/translit.h"
#include "unicode/rbt.h"
#include "unicode/unistr.h"
#include "unicode/calendar.h"
#include "unicode/datefmt.h"
@ -43,7 +42,7 @@ int main(int argc, char **argv) {
defFmt->setCalendar(*cal);
// Create a Greek-Latin Transliterator
greek_latin = Transliterator::createInstance("Greek-Latin");
greek_latin = Transliterator::createInstance("Greek-Latin", UTRANS_FORWARD, status);
if (greek_latin == nullptr) {
printf("ERROR: Transliterator::createInstance() failed\n");
exit(1);

View file

@ -9,7 +9,7 @@
***********************************************************************/
#include "unicode/translit.h"
#include "unicode/rbt.h"
#include "rbt.h"
#include "unicode/unistr.h"
#include "unicode/calendar.h"
#include "unicode/datefmt.h"
@ -55,16 +55,19 @@ int main(int argc, char **argv) {
defFmt->setCalendar(*cal);
// Create a Greek-Latin Transliterator
greek_latin = Transliterator::createInstance("Greek-Latin");
greek_latin = Transliterator::createInstance("Greek-Latin", UTRANS_FORWARD, status);
if (greek_latin == nullptr) {
printf("ERROR: Transliterator::createInstance() failed\n");
exit(1);
}
// Create a custom Transliterator
UParseError parseError;
rbtUnaccent = new RuleBasedTransliterator("RBTUnaccent",
UNACCENT_RULES,
UTRANS_FORWARD,
nullptr,
parseError,
status);
check(status, "RuleBasedTransliterator::ct");

View file

@ -9,7 +9,7 @@
***********************************************************************/
#include "unicode/translit.h"
#include "unicode/rbt.h"
#include "rbt.h"
#include "unicode/unistr.h"
#include "unicode/calendar.h"
#include "unicode/datefmt.h"
@ -56,16 +56,19 @@ int main(int argc, char **argv) {
defFmt->setCalendar(*cal);
// Create a Greek-Latin Transliterator
greek_latin = Transliterator::createInstance("Greek-Latin");
greek_latin = Transliterator::createInstance("Greek-Latin", UTRANS_FORWARD, status);
if (greek_latin == nullptr) {
printf("ERROR: Transliterator::createInstance() failed\n");
exit(1);
}
// Create a custom Transliterator
UParseError parseError;
rbtUnaccent = new RuleBasedTransliterator("RBTUnaccent",
UNACCENT_RULES,
UTRANS_FORWARD,
nullptr,
parseError,
status);
check(status, "RuleBasedTransliterator::ct");

View file

@ -13,11 +13,13 @@ using icu::Replaceable;
using icu::Transliterator;
using icu::UnicodeString;
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UnaccentTransliterator)
/**
* Constructor
*/
UnaccentTransliterator::UnaccentTransliterator() :
normalizer("", Normalizer::DECOMP),
normalizer("", UNORM_NFD),
Transliterator("Unaccent", nullptr) {
}

View file

@ -29,6 +29,9 @@ class UnaccentTransliterator : public Transliterator {
*/
virtual ~UnaccentTransliterator();
virtual UClassID getDynamicClassID() const override;
U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
protected:
/**