U_CAPI UCharDirection U_EXPORT2 u_charDirection(UChar32 c) { UErrorCode errorCode=U_ZERO_ERROR; const UBiDiProps *bdp=ubidi_getSingleton(&errorCode); if(bdp!=NULL) { return ubidi_getClass(bdp, c); } else { return U_LEFT_TO_RIGHT; } }
/* * This function shapes European digits to Arabic-Indic digits * in-place, writing over the input characters. * Since we know that we are only looking for BMP code points, * we can safely just work with code units (again, at least UTF-16). */ static void _shapeToArabicDigitsWithContext(UChar *s, int32_t length, UChar digitBase, UBool isLogical, UBool lastStrongWasAL) { const UBiDiProps *bdp; UErrorCode errorCode; int32_t i; UChar c; errorCode=U_ZERO_ERROR; bdp=ubidi_getSingleton(&errorCode); if(U_FAILURE(errorCode)) { return; } digitBase-=0x30; /* the iteration direction depends on the type of input */ if(isLogical) { for(i=0; i<length; ++i) { c=s[i]; switch(ubidi_getClass(bdp, c)) { case U_LEFT_TO_RIGHT: /* L */ case U_RIGHT_TO_LEFT: /* R */ lastStrongWasAL=FALSE; break; case U_RIGHT_TO_LEFT_ARABIC: /* AL */ lastStrongWasAL=TRUE; break; case U_EUROPEAN_NUMBER: /* EN */ if(lastStrongWasAL && (uint32_t)(c-0x30)<10) { s[i]=(UChar)(digitBase+c); /* digitBase+(c-0x30) - digitBase was modified above */ } break; default : break; } } } else { for(i=length; i>0; /* pre-decrement in the body */) { c=s[--i]; switch(ubidi_getClass(bdp, c)) { case U_LEFT_TO_RIGHT: /* L */ case U_RIGHT_TO_LEFT: /* R */ lastStrongWasAL=FALSE; break; case U_RIGHT_TO_LEFT_ARABIC: /* AL */ lastStrongWasAL=TRUE; break; case U_EUROPEAN_NUMBER: /* EN */ if(lastStrongWasAL && (uint32_t)(c-0x30)<10) { s[i]=(UChar)(digitBase+c); /* digitBase+(c-0x30) - digitBase was modified above */ } break; default : break; } } } }
U_CFUNC UCharDirection u_charDirection(UChar32 c) { return ubidi_getClass(&ubidi_props_singleton, c); }