apokryfos
apokryfos

Reputation: 40663

Inconsistent behaviour for number formatter with ordinal

I've encountered the oddest thing today and I'm not sure what to make of it.

Here's my code:

<?php 
$nf = new \NumberFormatter("en_UK", \NumberFormatter::ORDINAL);
die(var_dump($nf->format(1)));

This code outputs the following in PHP version 5.6.20:

string(3) "1st"

but it outputs the following in PHP version 5.6.14:

string(6) "1ˢᵗ"

I'm not sure what to make of this. The superscripted version is something I was not expecting. I went through the change logs but haven't seen this change documented. Anyone know if this is intended behaviour? Any way to force it back to the first behaviour (because it looks odd when rendering it in forms)?

The PHP 5.6.20 installation is using ICU version 4.8.1.1 while 5.6.14 is using ICU version 4.4.0.1

Upvotes: 1

Views: 95

Answers (1)

Steven R. Loomis
Steven R. Loomis

Reputation: 4350

I'd just upgrade to a newer ICU.

The strange superscript was fixed in CLDR 2.0 It was introduced in this ticket years before. I'm not sure which CLDR version introduced it, but unfortunately my name is on as the reviewer. Maybe it seemed like a good idea at the time.

This is data from CLDR and not code, usually we don't make a changelog entry for each data change.

Upvotes: 1

Related Questions