Remove usage of FXSYS_*ASCIIlower/upper methods

This replaces them with equivalent FXSYS_*wlower/upper methods, which
uses ICU to perform the correct Unicode operations.

BUG=pdfium:1035

Change-Id: I432db5bef9eda71762016b619d93155949d054db
Reviewed-on: https://pdfium-review.googlesource.com/28530
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: Ryan Harrison <rharrison@chromium.org>
diff --git a/core/fxcrt/bytestring.cpp b/core/fxcrt/bytestring.cpp
index 2a57602..f5687c5 100644
--- a/core/fxcrt/bytestring.cpp
+++ b/core/fxcrt/bytestring.cpp
@@ -344,8 +344,8 @@
   const uint8_t* pThat = str.raw_str();
   for (size_t i = 0; i < len; i++) {
     if ((*pThis) != (*pThat)) {
-      uint8_t bThis = FXSYS_toASCIIlower(*pThis);
-      uint8_t bThat = FXSYS_toASCIIlower(*pThat);
+      uint8_t bThis = tolower(*pThis);
+      uint8_t bThat = tolower(*pThat);
       if (bThis != bThat)
         return false;
     }
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 7bfcec6..4448a71 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -68,8 +68,8 @@
   ASSERT(s1 && s2 && count > 0);
   wchar_t wch1 = 0, wch2 = 0;
   while (count-- > 0) {
-    wch1 = static_cast<wchar_t>(FXSYS_toASCIIlower(*s1++));
-    wch2 = static_cast<wchar_t>(FXSYS_toASCIIlower(*s2++));
+    wch1 = static_cast<wchar_t>(FXSYS_towlower(*s1++));
+    wch2 = static_cast<wchar_t>(FXSYS_towlower(*s2++));
     if (wch1 != wch2)
       break;
   }
@@ -80,7 +80,7 @@
   uint32_t dwHashCode = 0;
   if (bIgnoreCase) {
     for (const auto& c : str)
-      dwHashCode = 31 * dwHashCode + FXSYS_toASCIIlower(c);
+      dwHashCode = 31 * dwHashCode + tolower(c);
   } else {
     for (const auto& c : str)
       dwHashCode = 31 * dwHashCode + c;
@@ -92,7 +92,7 @@
   uint32_t dwHashCode = 0;
   if (bIgnoreCase) {
     for (const auto& c : str)
-      dwHashCode = 1313 * dwHashCode + FXSYS_toASCIIlower(c);
+      dwHashCode = 1313 * dwHashCode + FXSYS_towlower(c);
   } else {
     for (const auto& c : str)
       dwHashCode = 1313 * dwHashCode + c;
diff --git a/core/fxcrt/fx_extension.h b/core/fxcrt/fx_extension.h
index 8e9d066..0f249f8 100644
--- a/core/fxcrt/fx_extension.h
+++ b/core/fxcrt/fx_extension.h
@@ -26,20 +26,20 @@
 wchar_t* FXSYS_wcsncpy(wchar_t* dstStr, const wchar_t* srcStr, size_t count);
 int32_t FXSYS_wcsnicmp(const wchar_t* s1, const wchar_t* s2, size_t count);
 
-inline bool FXSYS_isASCIIlower(int32_t ch) {
-  return ch >= 'a' && ch <= 'z';
+inline bool FXSYS_iswlower(int32_t c) {
+  return u_islower(c);
 }
 
-inline bool FXSYS_isASCIIupper(int32_t ch) {
-  return ch >= 'A' && ch <= 'Z';
+inline bool FXSYS_iswupper(int32_t c) {
+  return u_isupper(c);
 }
 
-inline int32_t FXSYS_toASCIIlower(int32_t ch) {
-  return ch < 'A' || ch > 'Z' ? ch : (ch + 0x20);
+inline int32_t FXSYS_towlower(wchar_t c) {
+  return u_tolower(c);
 }
 
-inline int32_t FXSYS_toASCIIupper(int32_t ch) {
-  return ch < 'a' || ch > 'z' ? ch : (ch - 0x20);
+inline int32_t FXSYS_towupper(wchar_t c) {
+  return u_toupper(c);
 }
 
 inline bool FXSYS_iswalpha(wchar_t c) {
diff --git a/core/fxcrt/fx_system.cpp b/core/fxcrt/fx_system.cpp
index 532e83b..27cbd65 100644
--- a/core/fxcrt/fx_system.cpp
+++ b/core/fxcrt/fx_system.cpp
@@ -118,7 +118,7 @@
   }
   char* s = str;
   while (*str) {
-    *str = FXSYS_toASCIIlower(*str);
+    *str = tolower(*str);
     str++;
   }
   return s;
@@ -129,7 +129,7 @@
   }
   char* s = str;
   while (*str) {
-    *str = FXSYS_toASCIIupper(*str);
+    *str = toupper(*str);
     str++;
   }
   return s;
@@ -140,7 +140,7 @@
   }
   wchar_t* s = str;
   while (*str) {
-    *str = FXSYS_toASCIIlower(*str);
+    *str = FXSYS_towlower(*str);
     str++;
   }
   return s;
@@ -151,7 +151,7 @@
   }
   wchar_t* s = str;
   while (*str) {
-    *str = FXSYS_toASCIIupper(*str);
+    *str = FXSYS_towupper(*str);
     str++;
   }
   return s;
@@ -161,8 +161,8 @@
   int f;
   int l;
   do {
-    f = FXSYS_toASCIIupper(*dst);
-    l = FXSYS_toASCIIupper(*src);
+    f = toupper(*dst);
+    l = toupper(*src);
     ++dst;
     ++src;
   } while (f && f == l);
@@ -173,8 +173,8 @@
   wchar_t f;
   wchar_t l;
   do {
-    f = FXSYS_toASCIIupper(*dst);
-    l = FXSYS_toASCIIupper(*src);
+    f = FXSYS_towupper(*dst);
+    l = FXSYS_towupper(*src);
     ++dst;
     ++src;
   } while (f && f == l);
diff --git a/core/fxge/android/cfpf_skiafontmgr.cpp b/core/fxge/android/cfpf_skiafontmgr.cpp
index 7413a69..d44d7d5 100644
--- a/core/fxge/android/cfpf_skiafontmgr.cpp
+++ b/core/fxge/android/cfpf_skiafontmgr.cpp
@@ -97,7 +97,7 @@
   const char* pStrEnd = pStr + iLength;
   uint32_t uHashCode = 0;
   while (pStr < pStrEnd)
-    uHashCode = 31 * uHashCode + FXSYS_toASCIIlower(*pStr++);
+    uHashCode = 31 * uHashCode + tolower(*pStr++);
   return uHashCode;
 }
 
@@ -167,7 +167,7 @@
     char ch = pBuffer[i];
     if (ch == ' ' || ch == '-' || ch == ',')
       continue;
-    dwHash = 31 * dwHash + FXSYS_toASCIIlower(ch);
+    dwHash = 31 * dwHash + tolower(ch);
   }
   return dwHash;
 }
diff --git a/fpdfsdk/pwl/cpwl_list_impl.cpp b/fpdfsdk/pwl/cpwl_list_impl.cpp
index 561ef1b..8795a67 100644
--- a/fpdfsdk/pwl/cpwl_list_impl.cpp
+++ b/fpdfsdk/pwl/cpwl_list_impl.cpp
@@ -608,8 +608,7 @@
       nCircleIndex = 0;
 
     if (Item* pListItem = m_ListItems[nCircleIndex].get()) {
-      if (FXSYS_toASCIIupper(pListItem->GetFirstChar()) ==
-          FXSYS_toASCIIupper(nChar))
+      if (FXSYS_towupper(pListItem->GetFirstChar()) == FXSYS_towupper(nChar))
         return nCircleIndex;
     }
   }
diff --git a/fxjs/cfxjse_formcalc_context.cpp b/fxjs/cfxjse_formcalc_context.cpp
index 14053c8..4157c29 100644
--- a/fxjs/cfxjse_formcalc_context.cpp
+++ b/fxjs/cfxjse_formcalc_context.cpp
@@ -1892,7 +1892,7 @@
     iIndex += kSubSecondLength;
   }
 
-  if (iIndex < iLength && FXSYS_toASCIIlower(pData[iIndex]) == 'z')
+  if (iIndex < iLength && FXSYS_towlower(pData[iIndex]) == 'z')
     return true;
 
   int32_t iSign = 1;
diff --git a/fxjs/cjs_util.cpp b/fxjs/cjs_util.cpp
index 25d4590..883d022 100644
--- a/fxjs/cjs_util.cpp
+++ b/fxjs/cjs_util.cpp
@@ -264,9 +264,9 @@
 enum CaseMode { kPreserveCase, kUpperCase, kLowerCase };
 
 static wchar_t TranslateCase(wchar_t input, CaseMode eMode) {
-  if (eMode == kLowerCase && FXSYS_isASCIIupper(input))
+  if (eMode == kLowerCase && FXSYS_iswupper(input))
     return input | 0x20;
-  if (eMode == kUpperCase && FXSYS_isASCIIlower(input))
+  if (eMode == kUpperCase && FXSYS_iswlower(input))
     return input & ~0x20;
   return input;
 }