diff --git a/src/util/Transcoders/ICU/ICUTransService.cpp b/src/util/Transcoders/ICU/ICUTransService.cpp index f365b9aa90463327ddd46df9a0c431ad6d5e1768..4b40a2ba576358f128a7681ebc6c8a3a6b8cba68 100644 --- a/src/util/Transcoders/ICU/ICUTransService.cpp +++ b/src/util/Transcoders/ICU/ICUTransService.cpp @@ -791,8 +791,14 @@ unsigned int ICULCPTranscoder::calcRequiredSize(const char* const srcText) if (err != U_BUFFER_OVERFLOW_ERROR) return 0; +#if (U_ICU_VERSION_MAJOR_NUM < 2) // Subtract one since it includes the terminator space return (unsigned int)(targetCap - 1); +#else + // Starting ICU 2.0, this is fixed and all ICU String functions have consistent NUL-termination behavior. + // The returned length is always the number of output UChar's, not counting an additional, terminating NUL. + return (unsigned int)(targetCap); +#endif }