| OLD | NEW |
| 1 /* | 1 /* |
| 2 ****************************************************************************** | 2 ****************************************************************************** |
| 3 * | 3 * |
| 4 * Copyright (C) 2001-2013, International Business Machines | 4 * Copyright (C) 2001-2014, International Business Machines |
| 5 * Corporation and others. All Rights Reserved. | 5 * Corporation and others. All Rights Reserved. |
| 6 * | 6 * |
| 7 ****************************************************************************** | 7 ****************************************************************************** |
| 8 * | 8 * |
| 9 * File ustrtrns.cpp | 9 * File ustrtrns.cpp |
| 10 * | 10 * |
| 11 * Modification History: | 11 * Modification History: |
| 12 * | 12 * |
| 13 * Date Name Description | 13 * Date Name Description |
| 14 * 9/10/2001 Ram Creation. | 14 * 9/10/2001 Ram Creation. |
| (...skipping 12 matching lines...) Expand all Loading... |
| 27 #include "unicode/putil.h" | 27 #include "unicode/putil.h" |
| 28 #include "unicode/ustring.h" | 28 #include "unicode/ustring.h" |
| 29 #include "unicode/utf.h" | 29 #include "unicode/utf.h" |
| 30 #include "unicode/utf8.h" | 30 #include "unicode/utf8.h" |
| 31 #include "unicode/utf16.h" | 31 #include "unicode/utf16.h" |
| 32 #include "cstring.h" | 32 #include "cstring.h" |
| 33 #include "cmemory.h" | 33 #include "cmemory.h" |
| 34 #include "ustr_imp.h" | 34 #include "ustr_imp.h" |
| 35 #include "uassert.h" | 35 #include "uassert.h" |
| 36 | 36 |
| 37 #define LENGTHOF(array) (int32_t)(sizeof(array)/sizeof((array)[0])) | |
| 38 | |
| 39 U_CAPI UChar* U_EXPORT2 | 37 U_CAPI UChar* U_EXPORT2 |
| 40 u_strFromUTF32WithSub(UChar *dest, | 38 u_strFromUTF32WithSub(UChar *dest, |
| 41 int32_t destCapacity, | 39 int32_t destCapacity, |
| 42 int32_t *pDestLength, | 40 int32_t *pDestLength, |
| 43 const UChar32 *src, | 41 const UChar32 *src, |
| 44 int32_t srcLength, | 42 int32_t srcLength, |
| 45 UChar32 subchar, int32_t *pNumSubstitutions, | 43 UChar32 subchar, int32_t *pNumSubstitutions, |
| 46 UErrorCode *pErrorCode) { | 44 UErrorCode *pErrorCode) { |
| 47 const UChar32 *srcLimit; | 45 const UChar32 *srcLimit; |
| 48 UChar32 ch; | 46 UChar32 ch; |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 case 0: | 374 case 0: |
| 377 return U_SENTINEL; | 375 return U_SENTINEL; |
| 378 /* no default branch to optimize switch() - all values are covered */ | 376 /* no default branch to optimize switch() - all values are covered */ |
| 379 } | 377 } |
| 380 } else { | 378 } else { |
| 381 illegal=1; /* too few bytes left */ | 379 illegal=1; /* too few bytes left */ |
| 382 } | 380 } |
| 383 | 381 |
| 384 /* correct sequence - all trail bytes have (b7..b6)==(10)? */ | 382 /* correct sequence - all trail bytes have (b7..b6)==(10)? */ |
| 385 /* illegal is also set if count>=4 */ | 383 /* illegal is also set if count>=4 */ |
| 386 U_ASSERT(illegal || count<LENGTHOF(utf8_minLegal)); | 384 U_ASSERT(illegal || count<UPRV_LENGTHOF(utf8_minLegal)); |
| 387 if(illegal || c<utf8_minLegal[count] || U_IS_SURROGATE(c)) { | 385 if(illegal || c<utf8_minLegal[count] || U_IS_SURROGATE(c)) { |
| 388 /* error handling */ | 386 /* error handling */ |
| 389 /* don't go beyond this sequence */ | 387 /* don't go beyond this sequence */ |
| 390 s=*ps; | 388 s=*ps; |
| 391 while(count>0 && s<limit && U8_IS_TRAIL(*s)) { | 389 while(count>0 && s<limit && U8_IS_TRAIL(*s)) { |
| 392 ++s; | 390 ++s; |
| 393 --count; | 391 --count; |
| 394 } | 392 } |
| 395 c=U_SENTINEL; | 393 c=U_SENTINEL; |
| 396 } | 394 } |
| (...skipping 1242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1639 | 1637 |
| 1640 reqLength+=(int32_t)(pDest - (uint8_t *)dest); | 1638 reqLength+=(int32_t)(pDest - (uint8_t *)dest); |
| 1641 if(pDestLength){ | 1639 if(pDestLength){ |
| 1642 *pDestLength = reqLength; | 1640 *pDestLength = reqLength; |
| 1643 } | 1641 } |
| 1644 | 1642 |
| 1645 /* Terminate the buffer */ | 1643 /* Terminate the buffer */ |
| 1646 u_terminateChars(dest, destCapacity, reqLength, pErrorCode); | 1644 u_terminateChars(dest, destCapacity, reqLength, pErrorCode); |
| 1647 return dest; | 1645 return dest; |
| 1648 } | 1646 } |
| OLD | NEW |