diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /intl/icu/source/i18n/remtrans.cpp | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'intl/icu/source/i18n/remtrans.cpp')
-rw-r--r-- | intl/icu/source/i18n/remtrans.cpp | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/intl/icu/source/i18n/remtrans.cpp b/intl/icu/source/i18n/remtrans.cpp new file mode 100644 index 0000000000..40af1845c7 --- /dev/null +++ b/intl/icu/source/i18n/remtrans.cpp @@ -0,0 +1,71 @@ +// © 2016 and later: Unicode, Inc. and others. +// License & terms of use: http://www.unicode.org/copyright.html +/* +********************************************************************** +* Copyright (c) 2001-2011, International Business Machines +* Corporation and others. All Rights Reserved. +********************************************************************** +* Date Name Description +* 04/02/2001 aliu Creation. +********************************************************************** +*/ + +#include "unicode/utypes.h" + +#if !UCONFIG_NO_TRANSLITERATION + +#include "remtrans.h" +#include "unicode/unifilt.h" + +static const char16_t CURR_ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x00}; /* "Any-Remove" */ + +U_NAMESPACE_BEGIN + +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RemoveTransliterator) + +/** + * Factory method + */ +static Transliterator* RemoveTransliterator_create(const UnicodeString& /*ID*/, + Transliterator::Token /*context*/) { + /* We don't need the ID or context. We just remove data */ + return new RemoveTransliterator(); +} + +/** + * System registration hook. + */ +void RemoveTransliterator::registerIDs() { + + Transliterator::_registerFactory(UnicodeString(true, ::CURR_ID, -1), + RemoveTransliterator_create, integerToken(0)); + + Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("Remove"), + UNICODE_STRING_SIMPLE("Null"), false); +} + +RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(true, ::CURR_ID, -1), 0) {} + +RemoveTransliterator::~RemoveTransliterator() {} + +RemoveTransliterator* RemoveTransliterator::clone() const { + RemoveTransliterator* result = new RemoveTransliterator(); + if (result != nullptr && getFilter() != 0) { + result->adoptFilter(getFilter()->clone()); + } + return result; +} + +void RemoveTransliterator::handleTransliterate(Replaceable& text, UTransPosition& index, + UBool /*isIncremental*/) const { + // Our caller (filteredTransliterate) has already narrowed us + // to an unfiltered run. Delete it. + UnicodeString empty; + text.handleReplaceBetween(index.start, index.limit, empty); + int32_t len = index.limit - index.start; + index.contextLimit -= len; + index.limit -= len; +} +U_NAMESPACE_END + +#endif /* #if !UCONFIG_NO_TRANSLITERATION */ |