diff options
Diffstat (limited to 'src/port/pgstrcasecmp.c')
-rw-r--r-- | src/port/pgstrcasecmp.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/port/pgstrcasecmp.c b/src/port/pgstrcasecmp.c index 1680124df0d..f6e226f0f2c 100644 --- a/src/port/pgstrcasecmp.c +++ b/src/port/pgstrcasecmp.c @@ -13,6 +13,10 @@ * * NB: this code should match downcase_truncate_identifier() in scansup.c. * + * We also provide strict ASCII-only case conversion functions, which can + * be used to implement C/POSIX case folding semantics no matter what the + * C library thinks the locale is. + * * * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group * @@ -123,3 +127,25 @@ pg_tolower(unsigned char ch) ch = tolower(ch); return ch; } + +/* + * Fold a character to upper case, following C/POSIX locale rules. + */ +unsigned char +pg_ascii_toupper(unsigned char ch) +{ + if (ch >= 'a' && ch <= 'z') + ch += 'A' - 'a'; + return ch; +} + +/* + * Fold a character to lower case, following C/POSIX locale rules. + */ +unsigned char +pg_ascii_tolower(unsigned char ch) +{ + if (ch >= 'A' && ch <= 'Z') + ch += 'a' - 'A'; + return ch; +} |