@@ -389,17 +389,17 @@ Handle<String> CurrencySignString(Isolate* isolate,
389389Handle<String> UnitDisplayString (Isolate* isolate,
390390 const icu::UnicodeString& skeleton) {
391391 // Ex: skeleton as
392- // "measure- unit/length-meter .### rounding-mode-half-up unit-width-full-name"
392+ // "unit/length-meter .### rounding-mode-half-up unit-width-full-name"
393393 if (skeleton.indexOf (" unit-width-full-name" ) >= 0 ) {
394394 return ReadOnlyRoots (isolate).long_string_handle ();
395395 }
396396 // Ex: skeleton as
397- // "measure- unit/length-meter .### rounding-mode-half-up unit-width-narrow".
397+ // "unit/length-meter .### rounding-mode-half-up unit-width-narrow".
398398 if (skeleton.indexOf (" unit-width-narrow" ) >= 0 ) {
399399 return ReadOnlyRoots (isolate).narrow_string_handle ();
400400 }
401401 // Ex: skeleton as
402- // "measure- unit/length-foot .### rounding-mode-half-up"
402+ // "unit/length-foot .### rounding-mode-half-up"
403403 return ReadOnlyRoots (isolate).short_string_handle ();
404404}
405405
@@ -422,7 +422,7 @@ Notation NotationFromSkeleton(const icu::UnicodeString& skeleton) {
422422 return Notation::COMPACT;
423423 }
424424 // Ex: skeleton as
425- // "measure- unit/length-foot .### rounding-mode-half-up"
425+ // "unit/length-foot .### rounding-mode-half-up"
426426 return Notation::STANDARD;
427427}
428428
@@ -562,14 +562,14 @@ namespace {
562562
563563// Ex: percent .### rounding-mode-half-up
564564// Special case for "percent"
565- // Ex: "measure- unit/length-kilometer per-measure-unit/duration-hour .###
566- // rounding-mode-half-up" should return "kilometer -per-unit ".
567- // Ex: "measure- unit/duration- year .### rounding-mode-half-up" should return
565+ // Ex: "unit/milliliter- per-acre .### rounding-mode-half-up"
566+ // should return "milliliter -per-acre ".
567+ // Ex: "unit/year .### rounding-mode-half-up" should return
568568// "year".
569569std::string UnitFromSkeleton (const icu::UnicodeString& skeleton) {
570570 std::string str;
571571 str = skeleton.toUTF8String <std::string>(str);
572- std::string search (" measure- unit/" );
572+ std::string search (" unit/" );
573573 size_t begin = str.find (search);
574574 if (begin == str.npos ) {
575575 // Special case for "percent".
@@ -578,64 +578,44 @@ std::string UnitFromSkeleton(const icu::UnicodeString& skeleton) {
578578 }
579579 return " " ;
580580 }
581- // Skip the type (ex: "length").
582- // "measure-unit/length-kilometer per-measure-unit/duration-hour"
583- // b
584- begin = str.find (" -" , begin + search.size ());
581+ // Ex:
582+ // "unit/acre .### rounding-mode-half-up"
583+ // b
584+ // Ex:
585+ // "unit/milliliter-per-acre .### rounding-mode-half-up"
586+ // b
587+ begin += search.size ();
585588 if (begin == str.npos ) {
586589 return " " ;
587590 }
588- begin++; // Skip the '-'.
589591 // Find the end of the subtype.
590592 size_t end = str.find (" " , begin);
591- // "measure-unit/length-kilometer per-measure-unit/duration-hour"
592- // b e
593+ // Ex:
594+ // "unit/acre .### rounding-mode-half-up"
595+ // b e
596+ // Ex:
597+ // "unit/milliliter-per-acre .### rounding-mode-half-up"
598+ // b e
593599 if (end == str.npos ) {
594600 end = str.size ();
595- return str.substr (begin, end - begin);
596- }
597- // "measure-unit/length-kilometer per-measure-unit/duration-hour"
598- // b e
599- // [result ]
600- std::string result = str.substr (begin, end - begin);
601- begin = end + 1 ;
602- // "measure-unit/length-kilometer per-measure-unit/duration-hour"
603- // [result ]eb
604- std::string search_per (" per-measure-unit/" );
605- begin = str.find (search_per, begin);
606- // "measure-unit/length-kilometer per-measure-unit/duration-hour"
607- // [result ]e b
608- if (begin == str.npos ) {
609- return result;
610- }
611- // Skip the type (ex: "duration").
612- begin = str.find (" -" , begin + search_per.size ());
613- // "measure-unit/length-kilometer per-measure-unit/duration-hour"
614- // [result ]e b
615- if (begin == str.npos ) {
616- return result;
617601 }
618- begin++; // Skip the '-'.
619- // "measure-unit/length-kilometer per-measure-unit/duration-hour"
620- // [result ]e b
621- end = str.find (" " , begin);
622- if (end == str.npos ) {
623- end = str.size ();
624- }
625- // "measure-unit/length-kilometer per-measure-unit/duration-hour"
626- // [result ] b e
627- return result + " -per-" + str.substr (begin, end - begin);
602+ return str.substr (begin, end - begin);
628603}
629604
630605Style StyleFromSkeleton (const icu::UnicodeString& skeleton) {
631606 if (skeleton.indexOf (" currency/" ) >= 0 ) {
632607 return Style::CURRENCY;
633608 }
634- if (skeleton.indexOf (" measure-unit/ " ) >= 0 ) {
635- if (skeleton. indexOf ( " scale/100 " ) >= 0 &&
636- skeleton.indexOf (" measure-unit/concentr-percent " ) >= 0 ) {
609+ if (skeleton.indexOf (" percent " ) >= 0 ) {
610+ // percent precision-integer rounding-mode-half-up scale/100
611+ if ( skeleton.indexOf (" scale/100 " ) >= 0 ) {
637612 return Style::PERCENT;
613+ } else {
614+ return Style::UNIT;
638615 }
616+ }
617+ // Before ICU68: "measure-unit/", since ICU68 "unit/"
618+ if (skeleton.indexOf (" unit/" ) >= 0 ) {
639619 return Style::UNIT;
640620 }
641621 return Style::DECIMAL;
0 commit comments