diff --git a/icu4c/source/common/ucnv_ext.c b/icu4c/source/common/ucnv_ext.c index 8e218616fec..e358a8b2fe9 100644 --- a/icu4c/source/common/ucnv_ext.c +++ b/icu4c/source/common/ucnv_ext.c @@ -663,7 +663,7 @@ ucnv_extMatchFromU(const int32_t *cx, /* return result */ if(matchValue==UCNV_EXT_FROM_U_SUBCHAR1) { - return 1; + return 1; /* assert matchLength==2 */ } *pMatchValue=UCNV_EXT_FROM_U_MASK_ROUNDTRIP(matchValue); diff --git a/icu4c/source/common/ucnv_ext.h b/icu4c/source/common/ucnv_ext.h index 29a683263f0..361ba73948c 100644 --- a/icu4c/source/common/ucnv_ext.h +++ b/icu4c/source/common/ucnv_ext.h @@ -269,6 +269,12 @@ * (i.e., "no mapping" with preference for rather than ), * and all other items are unique non-zero results. * + * The default value of a fromUTableValues[] section that is referenced + * _directly_ from a fromUStage3b[] item may also be UCNV_EXT_FROM_U_SUBCHAR1, + * but this value must not occur anywhere else in fromUTableValues[] + * because "no mapping" is always a property of a single code point, + * never of multiple. + * * * char fromUBytes[]; * diff --git a/icu4c/source/common/ucnvmbcs.c b/icu4c/source/common/ucnvmbcs.c index 6d8c8b836d1..d0b805b4c2c 100644 --- a/icu4c/source/common/ucnvmbcs.c +++ b/icu4c/source/common/ucnvmbcs.c @@ -3026,7 +3026,9 @@ getTrail: cnv->fromUnicodeStatus=prevLength; /* save the old state */ value=MBCS_VALUE_2_FROM_STAGE_2(bytes, stage2Entry, c); if(value<=0xff) { - if(prevLength<=1) { + if(value==0 && MBCS_FROM_U_IS_ROUNDTRIP(stage2Entry, c)==0) { + /* no mapping, leave value==0 */ + } else if(prevLength<=1) { length=1; } else { /* change from double-byte mode to single-byte */