| OLD | NEW |
| 1 /* | 1 /* |
| 2 ********************************************************************** | 2 ********************************************************************** |
| 3 * Copyright (C) 2000-2011, International Business Machines | 3 * Copyright (C) 2000-2014, International Business Machines |
| 4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
| 5 ********************************************************************** | 5 ********************************************************************** |
| 6 * file name: ucnvhz.c | 6 * file name: ucnvhz.c |
| 7 * encoding: US-ASCII | 7 * encoding: US-ASCII |
| 8 * tab size: 8 (not used) | 8 * tab size: 8 (not used) |
| 9 * indentation:4 | 9 * indentation:4 |
| 10 * | 10 * |
| 11 * created on: 2000oct16 | 11 * created on: 2000oct16 |
| 12 * created by: Ram Viswanadha | 12 * created by: Ram Viswanadha |
| 13 * 10/31/2000 Ram Implemented offsets logic function | 13 * 10/31/2000 Ram Implemented offsets logic function |
| 14 * | 14 * |
| 15 */ | 15 */ |
| 16 | 16 |
| 17 #include "unicode/utypes.h" | 17 #include "unicode/utypes.h" |
| 18 | 18 |
| 19 #if !UCONFIG_NO_CONVERSION && !UCONFIG_NO_LEGACY_CONVERSION && !UCONFIG_NO_NON_H
TML5_CONVERSION | 19 #if !UCONFIG_NO_CONVERSION && !UCONFIG_NO_LEGACY_CONVERSION |
| 20 | 20 |
| 21 #include "cmemory.h" | 21 #include "cmemory.h" |
| 22 #include "unicode/ucnv.h" | 22 #include "unicode/ucnv.h" |
| 23 #include "unicode/ucnv_cb.h" | 23 #include "unicode/ucnv_cb.h" |
| 24 #include "unicode/uset.h" | 24 #include "unicode/uset.h" |
| 25 #include "unicode/utf16.h" | 25 #include "unicode/utf16.h" |
| 26 #include "ucnv_bld.h" | 26 #include "ucnv_bld.h" |
| 27 #include "ucnv_cnv.h" | 27 #include "ucnv_cnv.h" |
| 28 #include "ucnv_imp.h" | 28 #include "ucnv_imp.h" |
| 29 | 29 |
| (...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 static void | 333 static void |
| 334 UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args, | 334 UConverter_fromUnicode_HZ_OFFSETS_LOGIC (UConverterFromUnicodeArgs * args, |
| 335 UErrorCode * err){ | 335 UErrorCode * err){ |
| 336 const UChar *mySource = args->source; | 336 const UChar *mySource = args->source; |
| 337 char *myTarget = args->target; | 337 char *myTarget = args->target; |
| 338 int32_t* offsets = args->offsets; | 338 int32_t* offsets = args->offsets; |
| 339 int32_t mySourceIndex = 0; | 339 int32_t mySourceIndex = 0; |
| 340 int32_t myTargetIndex = 0; | 340 int32_t myTargetIndex = 0; |
| 341 int32_t targetLength = (int32_t)(args->targetLimit - myTarget); | 341 int32_t targetLength = (int32_t)(args->targetLimit - myTarget); |
| 342 int32_t mySourceLength = (int32_t)(args->sourceLimit - args->source); | 342 int32_t mySourceLength = (int32_t)(args->sourceLimit - args->source); |
| 343 int32_t length=0; | |
| 344 uint32_t targetUniChar = 0x0000; | 343 uint32_t targetUniChar = 0x0000; |
| 345 UChar32 mySourceChar = 0x0000; | 344 UChar32 mySourceChar = 0x0000; |
| 346 UConverterDataHZ *myConverterData=(UConverterDataHZ*)args->converter->extraI
nfo; | 345 UConverterDataHZ *myConverterData=(UConverterDataHZ*)args->converter->extraI
nfo; |
| 347 UBool isTargetUCharDBCS = (UBool) myConverterData->isTargetUCharDBCS; | 346 UBool isTargetUCharDBCS = (UBool) myConverterData->isTargetUCharDBCS; |
| 348 UBool oldIsTargetUCharDBCS = isTargetUCharDBCS; | 347 UBool oldIsTargetUCharDBCS; |
| 349 int len =0; | 348 int len =0; |
| 350 const char* escSeq=NULL; | 349 const char* escSeq=NULL; |
| 351 | 350 |
| 352 /* Calling code already handles this situation. */ | 351 /* Calling code already handles this situation. */ |
| 353 /*if ((args->converter == NULL) || (args->targetLimit < myTarget) || (args->
sourceLimit < args->source)){ | 352 /*if ((args->converter == NULL) || (args->targetLimit < myTarget) || (args->
sourceLimit < args->source)){ |
| 354 *err = U_ILLEGAL_ARGUMENT_ERROR; | 353 *err = U_ILLEGAL_ARGUMENT_ERROR; |
| 355 return; | 354 return; |
| 356 }*/ | 355 }*/ |
| 357 if(args->converter->fromUChar32!=0 && myTargetIndex < targetLength) { | 356 if(args->converter->fromUChar32!=0 && myTargetIndex < targetLength) { |
| 358 goto getTrail; | 357 goto getTrail; |
| 359 } | 358 } |
| 360 /*writing the char to the output stream */ | 359 /*writing the char to the output stream */ |
| 361 while (mySourceIndex < mySourceLength){ | 360 while (mySourceIndex < mySourceLength){ |
| 362 targetUniChar = missingCharMarker; | 361 targetUniChar = missingCharMarker; |
| 363 if (myTargetIndex < targetLength){ | 362 if (myTargetIndex < targetLength){ |
| 364 | 363 |
| 365 mySourceChar = (UChar) mySource[mySourceIndex++]; | 364 mySourceChar = (UChar) mySource[mySourceIndex++]; |
| 366 | 365 |
| 367 | 366 |
| 368 oldIsTargetUCharDBCS = isTargetUCharDBCS; | 367 oldIsTargetUCharDBCS = isTargetUCharDBCS; |
| 369 if(mySourceChar ==UCNV_TILDE){ | 368 if(mySourceChar ==UCNV_TILDE){ |
| 370 /*concatEscape(args, &myTargetIndex, &targetLength,"\x7E\x7E",er
r,2,&mySourceIndex);*/ | 369 /*concatEscape(args, &myTargetIndex, &targetLength,"\x7E\x7E",er
r,2,&mySourceIndex);*/ |
| 371 len = ESC_LEN; | 370 len = ESC_LEN; |
| 372 escSeq = TILDE_ESCAPE; | 371 escSeq = TILDE_ESCAPE; |
| 373 CONCAT_ESCAPE_MACRO(args, myTargetIndex, targetLength, escSeq,er
r,len,mySourceIndex); | 372 CONCAT_ESCAPE_MACRO(args, myTargetIndex, targetLength, escSeq,er
r,len,mySourceIndex); |
| 374 continue; | 373 continue; |
| 375 } else if(mySourceChar <= 0x7f) { | 374 } else if(mySourceChar <= 0x7f) { |
| 376 length = 1; | |
| 377 targetUniChar = mySourceChar; | 375 targetUniChar = mySourceChar; |
| 378 } else { | 376 } else { |
| 379 length= ucnv_MBCSFromUChar32(myConverterData->gbConverter->share
dData, | 377 int32_t length= ucnv_MBCSFromUChar32(myConverterData->gbConverte
r->sharedData, |
| 380 mySourceChar,&targetUniChar,args->converter->useFallback); | 378 mySourceChar,&targetUniChar,args->converter->useFallback); |
| 381 /* we can only use lead bytes 21..7D and trail bytes 21..7E */ | 379 /* we can only use lead bytes 21..7D and trail bytes 21..7E */ |
| 382 if( length == 2 && | 380 if( length == 2 && |
| 383 (uint16_t)(targetUniChar - 0xa1a1) <= (0xfdfe - 0xa1a1) && | 381 (uint16_t)(targetUniChar - 0xa1a1) <= (0xfdfe - 0xa1a1) && |
| 384 (uint8_t)(targetUniChar - 0xa1) <= (0xfe - 0xa1) | 382 (uint8_t)(targetUniChar - 0xa1) <= (0xfe - 0xa1) |
| 385 ) { | 383 ) { |
| 386 targetUniChar -= 0x8080; | 384 targetUniChar -= 0x8080; |
| 387 } else { | 385 } else { |
| 388 targetUniChar = missingCharMarker; | 386 targetUniChar = missingCharMarker; |
| 389 } | 387 } |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 sizeof(UConverterSharedData), | 628 sizeof(UConverterSharedData), |
| 631 ~((uint32_t) 0), | 629 ~((uint32_t) 0), |
| 632 NULL, | 630 NULL, |
| 633 NULL, | 631 NULL, |
| 634 &_HZStaticData, | 632 &_HZStaticData, |
| 635 FALSE, | 633 FALSE, |
| 636 &_HZImpl, | 634 &_HZImpl, |
| 637 0 | 635 0 |
| 638 }; | 636 }; |
| 639 | 637 |
| 640 #endif /* #if !UCONFIG_NO_CONVERSION && !UCONFIG_NO_LEGACY_CONVERSION && !UCONFI
G_NO_NON_HTML5_CONVERSION */ | 638 #endif /* #if !UCONFIG_NO_LEGACY_CONVERSION */ |
| OLD | NEW |