// The maximized locale ID string is often longer, but there is no good
// heuristic to estimate just how much longer. Leave that to CharString.
CharString maximizedLocaleID;
- int32_t maximizedLocaleIDCapacity = uprv_strlen(fullName);
+ int32_t maximizedLocaleIDCapacity = static_cast<int32_t>(uprv_strlen(fullName));
char* buffer;
int32_t reslen;
// "en__POSIX"), minimized locale ID strings will be either the same length
// or shorter than their input.
CharString minimizedLocaleID;
- int32_t minimizedLocaleIDCapacity = uprv_strlen(fullName);
+ int32_t minimizedLocaleIDCapacity = static_cast<int32_t>(uprv_strlen(fullName));
char* buffer;
int32_t reslen;
// All simple language tags will have the exact same length as BCP-47
// strings as they have as ICU locale IDs (like "en-US" for "en_US").
LocalMemory<char> scratch;
- int32_t scratch_capacity = uprv_strlen(fullName);
+ int32_t scratch_capacity = static_cast<int32_t>(uprv_strlen(fullName));
if (scratch_capacity == 0) {
scratch_capacity = 3; // "und"
if (key == nullptr) {
status = U_ILLEGAL_ARGUMENT_ERROR;
} else {
- if (resultLength != nullptr) *resultLength = uprv_strlen(key);
+ if (resultLength != nullptr) {
+ *resultLength = static_cast<int32_t>(uprv_strlen(key));
+ }
return key;
}
}
return;
}
- sink.Append(unicode_value, uprv_strlen(unicode_value));
+ sink.Append(unicode_value, static_cast<int32_t>(uprv_strlen(unicode_value)));
}
void
julianDay += isLeap?kLeapNumDays[month]:kNumDays[month];
}
- return julianDay;
+ return static_cast<int32_t>(julianDay);
}
int32_t GregorianCalendar::handleGetMonthLength(int32_t extendedYear, int32_t month) const
inline int32_t Grego::gregorianShift(int32_t eyear) {
int64_t y = (int64_t)eyear-1;
- int32_t gregShift = ClockMath::floorDivide(y, (int64_t)400) - ClockMath::floorDivide(y, (int64_t)100) + 2;
+ int32_t gregShift = static_cast<int32_t>(ClockMath::floorDivide(y, (int64_t)400) - ClockMath::floorDivide(y, (int64_t)100) + 2);
return gregShift;
}
* A fill-in for getParameters(). obj will always be set; if non-null, the other
* two fields are also safe to read.
*/
- struct Parameters {
+ struct U_I18N_API Parameters {
const ModifierStore* obj = nullptr;
int8_t signum;
StandardPlural::Form plural;
return 0;
if(sSize <= 0) {
- sSize = uprv_strlen(s) + 1;
+ sSize = static_cast<int32_t>(uprv_strlen(s)) + 1;
}
/* perform the conversion in one swoop */
else {
pattern = buffer;
}
- u_charsToUChars(patternSpecification, pattern, size);
+ u_charsToUChars(patternSpecification, pattern, static_cast<int32_t>(size));
/* do the work */
count = u_vfprintf_u(f, pattern, ap);
/* Was the character consumed? */
if (us != uBuffer) {
/* Reminder: ibm-1390 & JISX0213 can output 2 Unicode code points */
- int32_t uBuffSize = us-uBuffer;
+ int32_t uBuffSize = static_cast<int32_t>(us-uBuffer);
int32_t uBuffIdx = 0;
while (uBuffIdx < uBuffSize) {
U16_NEXT(uBuffer, uBuffIdx, uBuffSize, ch32);
return NULL;
}
- long t = fread(result, 1, fileSize, file);
+ long t = static_cast<long>(fread(result, 1, fileSize, file));
if (t != fileSize) {
delete [] result;
fclose(file);
if (currStrLen > 0) {
int32_t normStrLen;
ucnv_io_stripForCompare(normalizedStrings, origStringBlock);
- normStrLen = uprv_strlen(normalizedStrings);
+ normStrLen = (int32_t)uprv_strlen(normalizedStrings);
if (normStrLen > 0) {
uprv_memset(normalizedStrings + normStrLen, 0, currStrSize - normStrLen);
}
if (*s == '@') {
/* special directive */
s++;
- length = fields[0][1] - s;
+ length = (int32_t)(fields[0][1] - s);
if (length >= NORMALIZE_DIRECTIVE_LEN
&& uprv_strncmp(s, NORMALIZE_DIRECTIVE, NORMALIZE_DIRECTIVE_LEN) == 0) {
options[NORMALIZE].doesOccur = TRUE;
static int runCommand(const char* command, UBool specialHandling) {
char *cmd = NULL;
char cmdBuffer[SMALL_BUFFER_MAX_SIZE];
- int32_t len = strlen(command);
+ int32_t len = static_cast<int32_t>(strlen(command));
if (len == 0) {
return 0;
if (f != NULL) {
for(;;) {
if (T_FileStream_readLine(f, buffer, SMALL_BUFFER_MAX_SIZE) != NULL) {
- bufferLength = uprv_strlen(buffer);
+ bufferLength = static_cast<int32_t>(uprv_strlen(buffer));
/* Remove new line character. */
if (bufferLength > 0) {
buffer[bufferLength-1] = 0;
U_CAPI int32_t U_EXPORT2
T_FileStream_read(FileStream* fileStream, void* addr, int32_t len)
{
- return fread(addr, 1, len, (FILE*)fileStream);
+ return static_cast<int32_t>(fread(addr, 1, len, (FILE*)fileStream));
}
U_CAPI int32_t U_EXPORT2
T_FileStream_write(FileStream* fileStream, const void* addr, int32_t len)
{
- return fwrite(addr, 1, len, (FILE*)fileStream);
+ return static_cast<int32_t>(fwrite(addr, 1, len, (FILE*)fileStream));
}
U_CAPI void U_EXPORT2
/* Swap the file separater character given with the new one in the file path. */
U_CAPI void U_EXPORT2
swapFileSepChar(char *filePath, const char oldFileSepChar, const char newFileSepChar) {
- for (int32_t i = 0, length = uprv_strlen(filePath); i < length; i++) {
+ for (int32_t i = 0, length = static_cast<int32_t>(uprv_strlen(filePath)); i < length; i++) {
filePath[i] = (filePath[i] == oldFileSepChar ) ? newFileSepChar : filePath[i];
}
}
memcpy(prefix, s, ++prefixLength); // include the /
} else {
// Use the package basename as prefix.
- int32_t inPkgNameLength=strlen(inPkgName);
+ int32_t inPkgNameLength= static_cast<int32_t>(strlen(inPkgName));
memcpy(prefix, inPkgName, inPkgNameLength);
prefixLength=inPkgNameLength;
memset(items+idx, 0, sizeof(Item));
// copy the item's name
- items[idx].name=allocString(TRUE, strlen(name));
+ items[idx].name=allocString(TRUE, static_cast<int32_t>(strlen(name)));
strcpy(items[idx].name, name);
pathToTree(items[idx].name);
} else {
paramStatic(const USystemParams *param, char *target, int32_t targetCapacity, UErrorCode *status) {
if(param->paramStr==NULL) return paramEmpty(param,target,targetCapacity,status);
if(U_FAILURE(*status))return 0;
- int32_t len = uprv_strlen(param->paramStr);
+ int32_t len = static_cast<int32_t>(uprv_strlen(param->paramStr));
if(target!=NULL) {
uprv_strncpy(target,param->paramStr,uprv_min(len,targetCapacity));
}
static int32_t stringToStringBuffer(char *target, int32_t targetCapacity, const char *str, UErrorCode *status) {
if(str==NULL) str=nullString;
- int32_t len = uprv_strlen(str);
+ int32_t len = static_cast<int32_t>(uprv_strlen(str));
if (U_SUCCESS(*status)) {
if(target!=NULL) {
uprv_strncpy(target,str,uprv_min(len,targetCapacity));
}
} else {
const char *s = u_errorName(*status);
- len = uprv_strlen(s);
+ len = static_cast<int32_t>(uprv_strlen(s));
if(target!=NULL) {
uprv_strncpy(target,s,uprv_min(len,targetCapacity));
}