Skip to content

Commit

Permalink
Add non-locale aware CPLTolower() and CPLToupper()
Browse files Browse the repository at this point in the history
  • Loading branch information
rouault committed Apr 14, 2024
1 parent 7598191 commit 19b0302
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
30 changes: 30 additions & 0 deletions port/cpl_string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3021,3 +3021,33 @@ char **CSLParseCommandLine(const char *pszCommandLine)
{
return CSLTokenizeString(pszCommandLine);
}

/************************************************************************/
/* CPLToupper() */
/************************************************************************/

/** Converts a (ASCII) lowercase character to uppercase.
*
* Same as standard toupper(), except that it is not locale sensitive.
*
* @since GDAL 3.9
*/
int CPLToupper(int c)
{
return (c >= 'a' && c <= 'z') ? (c - 'a' + 'A') : c;
}

/************************************************************************/
/* CPLTolower() */
/************************************************************************/

/** Converts a (ASCII) uppercase character to lowercase.
*
* Same as standard tolower(), except that it is not locale sensitive.
*
* @since GDAL 3.9
*/
int CPLTolower(int c)
{
return (c >= 'A' && c <= 'Z') ? (c - 'A' + 'a') : c;
}
3 changes: 3 additions & 0 deletions port/cpl_string.h
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ typedef enum

CPLValueType CPL_DLL CPLGetValueType(const char *pszValue);

int CPL_DLL CPLToupper(int c);
int CPL_DLL CPLTolower(int c);

size_t CPL_DLL CPLStrlcpy(char *pszDest, const char *pszSrc, size_t nDestSize);
size_t CPL_DLL CPLStrlcat(char *pszDest, const char *pszSrc, size_t nDestSize);
size_t CPL_DLL CPLStrnlen(const char *pszStr, size_t nMaxLen);
Expand Down

0 comments on commit 19b0302

Please sign in to comment.