X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/f3c0d7a59d99c2a94c6b8822291f0e42be3773c9..249c4c5ea9376c24572daf9c2effa7484a282f14:/icuSources/samples/ucnv/convsamp.cpp diff --git a/icuSources/samples/ucnv/convsamp.cpp b/icuSources/samples/ucnv/convsamp.cpp index 7194e6d4..a692b77b 100644 --- a/icuSources/samples/ucnv/convsamp.cpp +++ b/icuSources/samples/ucnv/convsamp.cpp @@ -130,7 +130,7 @@ void printBytes(const char *name = "?", int32_t i; if( (len == -1) && (uch) ) { - len = strlen(uch); + len = static_cast(strlen(uch)); } printf("%5s: ", name); @@ -329,7 +329,7 @@ UErrorCode convsample_05() // grab another buffer's worth while((!feof(f)) && - ((count=fread(inBuf, 1, BUFFERSIZE , f)) > 0) ) + ((count=static_cast(fread(inBuf, 1, BUFFERSIZE , f))) > 0) ) { // Convert bytes to unicode source = inBuf; @@ -424,7 +424,7 @@ UErrorCode convsample_06() info = (CharFreqInfo*)malloc(sizeof(CharFreqInfo) * charCount); if(!info) { - fprintf(stderr, " Couldn't allocate %d bytes for freq counter\n", sizeof(CharFreqInfo)*charCount); + fprintf(stderr, " Couldn't allocate %d bytes for freq counter\n", static_cast(sizeof(CharFreqInfo)*charCount)); } /* reset frequencies */ @@ -444,7 +444,7 @@ UErrorCode convsample_06() // grab another buffer's worth while((!feof(f)) && - ((count=fread(inBuf, 1, BUFFERSIZE , f)) > 0) ) + ((count=static_cast(fread(inBuf, 1, BUFFERSIZE , f))) > 0) ) { // Convert bytes to unicode source = inBuf; @@ -545,7 +545,7 @@ UErrorCode convsample_12() // convert to Unicode // Note: we can use strlen, we know it's an 8 bit null terminated codepage target[6] = 0xFDCA; - len = ucnv_toUChars(conv, target, 100, source, strlen(source), &status); + len = ucnv_toUChars(conv, target, 100, source, static_cast(strlen(source)), &status); U_ASSERT(status); // close the converter ucnv_close(conv); @@ -553,7 +553,7 @@ UErrorCode convsample_12() // ***************************** END SAMPLE ******************** // Print it out - printBytes("src", source, strlen(source) ); + printBytes("src", source, static_cast(strlen(source)) ); printf("\n"); printUChars("targ", target, len); @@ -590,7 +590,7 @@ UErrorCode convsample_13() // **************************** START SAMPLE ******************* - printBytes("src",source,sourceLimit-source); + printBytes("src", source, static_cast(sourceLimit - source)); while(source < sourceLimit) { @@ -640,7 +640,7 @@ UBool convsample_20_didSubstitute(const char *source) conv = ucnv_open("utf-8", &status); U_ASSERT(status); - len = ucnv_toUChars(conv, uchars, 100, source, strlen(source), &status); + len = ucnv_toUChars(conv, uchars, 100, source, static_cast(strlen(source)), &status); U_ASSERT(status); printUChars("uch", uchars, len); @@ -719,7 +719,6 @@ UBool convsample_21_didSubstitute(const char *source) UConverter *conv = NULL, *cloneCnv = NULL; UErrorCode status = U_ZERO_ERROR; uint32_t len, len2; - int32_t cloneLen; UBool flagVal = FALSE; UConverterFromUCallback junkCB; @@ -741,7 +740,7 @@ UBool convsample_21_didSubstitute(const char *source) conv = ucnv_open("utf-8", &status); U_ASSERT(status); - len = ucnv_toUChars(conv, uchars, 100, source, strlen(source), &status); + len = ucnv_toUChars(conv, uchars, 100, source, static_cast(strlen(source)), &status); U_ASSERT(status); printUChars("uch", uchars, len); @@ -916,7 +915,7 @@ UErrorCode convsample_40() // grab another buffer's worth while((!feof(f)) && - ((count=fread(inBuf, 1, BUFFERSIZE , f)) > 0) ) + ((count=static_cast(fread(inBuf, 1, BUFFERSIZE , f))) > 0) ) { inbytes += count; @@ -950,9 +949,8 @@ UErrorCode convsample_40() // Process the Unicode // Todo: handle UTF-16/surrogates - assert(fwrite(uBuf, sizeof(uBuf[0]), (target-uBuf), out) == - (size_t)(target-uBuf)); - total += (target-uBuf); + assert(fwrite(uBuf, sizeof(uBuf[0]), (target-uBuf), out) == (size_t)(target-uBuf)); + total += static_cast((target-uBuf)); } while (source < sourceLimit); // while simply out of space } @@ -1022,7 +1020,7 @@ UErrorCode convsample_46() // grab another buffer's worth while((!feof(f)) && - ((count=fread(inBuf, sizeof(UChar), BUFFERSIZE , f)) > 0) ) + ((count=static_cast(fread(inBuf, sizeof(UChar), BUFFERSIZE , f))) > 0) ) { inchars += count; @@ -1055,13 +1053,12 @@ UErrorCode convsample_46() } // Process the Unicode - assert(fwrite(buf, sizeof(buf[0]), (target-buf), out) == - (size_t)(target-buf)); - total += (target-buf); + assert(fwrite(buf, sizeof(buf[0]), (target-buf), out) == (size_t)(target-buf)); + total += static_cast((target-buf)); } while (source < sourceLimit); // while simply out of space } - printf("%d Uchars (%d bytes) in, %d chars out.\n", inchars, inchars * sizeof(UChar), total); + printf("%d Uchars (%d bytes) in, %d chars out.\n", inchars, static_cast(inchars * sizeof(UChar)), total); // ***************************** END SAMPLE ******************** ucnv_close(conv);