diff --git a/icu4c/source/io/ustdio.c b/icu4c/source/io/ustdio.c index d4f4bf465e..051babae75 100644 --- a/icu4c/source/io/ustdio.c +++ b/icu4c/source/io/ustdio.c @@ -283,9 +283,9 @@ u_fputc(UChar32 uc, U16_APPEND(buf, idx, sizeof(buf)/sizeof(*buf), uc, isError); if (isError) { - return EOF; + return U_EOF; } - return u_file_write(buf, idx, f) == idx ? uc : EOF; + return u_file_write(buf, idx, f) == idx ? uc : U_EOF; } diff --git a/icu4c/source/test/iotest/filetst.c b/icu4c/source/test/iotest/filetst.c index 1a98d899df..4f8d0bcad5 100644 --- a/icu4c/source/test/iotest/filetst.c +++ b/icu4c/source/test/iotest/filetst.c @@ -433,6 +433,12 @@ static void TestfgetsBuffers(void) { } u_fputc(0x3BC, myFile); + if (u_fputc(0x110000, myFile) != U_EOF) { + log_err("u_fputc should return U_EOF for 0x110000.\n"); + } + if (u_fputc((UChar32)0xFFFFFFFFu, myFile) != U_EOF) { + log_err("u_fputc should return U_EOF for 0xFFFFFFFF.\n"); + } u_fputc(0xFF41, myFile); u_memset(buffer, 0xBEEF, sizeof(buffer)/sizeof(buffer[0])); u_memset(expectedBuffer, 0, sizeof(expectedBuffer)/sizeof(expectedBuffer[0]));