U_MISSING_RESOURCE_ERROR when loading "fallback" pattern

Description

Loading the "fallback" pattern doesn't work correctly for {{UDateIntervalFormat}} (and {{icu::DateIntervalFormat}}).

 

This is blocking the implementation of the ECMA-402 proposal <https://github.com/tc39/proposal-intl-DateTimeFormat-formatRange>.

 

Test case:

* Expected: No error

* Actual: Prints {{"udtitvfmt_open failed: U_MISSING_RESOURCE_ERROR"}}

 

{code:cpp}

#include <cstddef>

#include <cstdint>

#include <cstdio>

#include <string>

#include <utility>

 

#include "unicode/udateintervalformat.h"

#include "unicode/ustdio.h"

#include "unicode/utypes.h"

 

#define CHECK_OR_RETURN(name, status) \

if (U_FAILURE(status)) { printf("%s failed: %s\n", name, u_errorName(status)); return 1; }

 

class UDateIntervalFormatDeleter {

public:

void operator()(UDateIntervalFormat* aPtr) {

udtitvfmt_close(aPtr);

}

};

using UniqueUDateIntervalFormat = std::unique_ptr<UDateIntervalFormat, UDateIntervalFormatDeleter>;

 

int main() {

const char* locale = "cs-u-ca-hebrew";

const char16_t* skeleton = u"yyyyMMdd";

const char16_t* tzID = u"UTC";

 

UErrorCode status = U_ZERO_ERROR;

UniqueUDateIntervalFormat dif(

udtitvfmt_open(locale,

skeleton, std::char_traits<char16_t>::length(skeleton),

tzID, std::char_traits<char16_t>::length(tzID),

&status));

CHECK_OR_RETURN("udtitvfmt_open", status);

 

return 0;

}

{code}

 

 

Reduced test case based on [this code|https://github.com/unicode-org/icu/blob/d56f291178bd63fae22c4f528f31fd5d9610b4fb/icu4c/source/i18n/dtitvinf.cpp#L421-L434]:

{code:cpp}

#include <cstddef>

#include <cstdint>

#include <cstdio>

 

#include "unicode/ustdio.h"

#include "unicode/utypes.h"

 

#include "unicode/localpointer.h"

#include "unicode/resbund.h"

 

#define CHECK_OR_RETURN(name, status) \

if (U_FAILURE(status)) { printf("%s failed: %s\n", name, u_errorName(status)); return 1; }

 

int main() {

UErrorCode status = U_ZERO_ERROR;

 

const char* locale = "cs@calendar=hebrew";

 

icu::ResourceBundle rb(nullptr, icu::Locale(locale), status);

CHECK_OR_RETURN("ures_open", status);

 

icu::ResourceBundle calBundle = rb.getWithFallback("calendar", status);

CHECK_OR_RETURN("getWithFallback::calendar", status);

 

icu::ResourceBundle calTypeBundle = calBundle.getWithFallback("islamic-civil", status);

CHECK_OR_RETURN("getWithFallback::calendar-type", status);

 

icu::ResourceBundle itvDtPtnResource = calTypeBundle.getWithFallback("intervalFormats", status);

CHECK_OR_RETURN("getWithFallback::intervalFormats", status);

 

icu::ResourceBundle fallbackBundle = itvDtPtnResource.getWithFallback("fallback", status);

CHECK_OR_RETURN("getWithFallback::fallback", status);

 

printf("success - resource found!\n");

 

return 0;

}

{code}

Assignee

Frank Yung-Fong Tang

Reporter

André Bargull

Components

Labels

Reviewer

Yoshito Umaoka

Priority

major

Time Needed

None

Fix versions

Configure