Move WideString::WStringLength() to cpdfsdk_helpers.cpp

FPDF_WIDESTRING != WideString, and the former is use only in the public
API, so avoid some confusion by moving this code into fpdfsdk.

-- rename to FPDFWideStringLength()

Change-Id: I56fd679fccc2580fb3718c475d7b88a235a18394
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/116451
Reviewed-by: Thomas Sepez <tsepez@google.com>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Commit-Queue: Tom Sepez <tsepez@chromium.org>
diff --git a/core/fxcrt/widestring.cpp b/core/fxcrt/widestring.cpp
index 179a03e..d4155c0 100644
--- a/core/fxcrt/widestring.cpp
+++ b/core/fxcrt/widestring.cpp
@@ -1081,14 +1081,6 @@
   return (!str || str[0] == 0) ? 0 : -1;
 }
 
-size_t WideString::WStringLength(const unsigned short* str) {
-  size_t len = 0;
-  if (str)
-    while (str[len])
-      len++;
-  return len;
-}
-
 void WideString::Trim() {
   TrimRight(kWideTrimChars);
   TrimLeft(kWideTrimChars);
diff --git a/core/fxcrt/widestring.h b/core/fxcrt/widestring.h
index 244c56a..ae79e11 100644
--- a/core/fxcrt/widestring.h
+++ b/core/fxcrt/widestring.h
@@ -74,8 +74,6 @@
   [[nodiscard]] static WideString FromUTF16LE(pdfium::span<const uint8_t> data);
   [[nodiscard]] static WideString FromUTF16BE(pdfium::span<const uint8_t> data);
 
-  [[nodiscard]] static size_t WStringLength(const unsigned short* str);
-
   // Explicit conversion to C-style wide string.  The result is never nullptr,
   // and is always NUL terminated.
   // Note: Any subsequent modification of |this| will invalidate the result.
diff --git a/fpdfsdk/cpdfsdk_helpers.cpp b/fpdfsdk/cpdfsdk_helpers.cpp
index 4d5020f..7484d25 100644
--- a/fpdfsdk/cpdfsdk_helpers.cpp
+++ b/fpdfsdk/cpdfsdk_helpers.cpp
@@ -72,6 +72,17 @@
   return pdfium::base::checked_cast<unsigned long>(stream_data_span.size());
 }
 
+size_t FPDFWideStringLength(const unsigned short* str) {
+  if (!str) {
+    return 0;
+  }
+  size_t len = 0;
+  while (str[len]) {
+    len++;
+  }
+  return len;
+}
+
 #ifdef PDF_ENABLE_XFA
 class FPDF_FileHandlerContext final : public IFX_SeekableStream {
  public:
@@ -211,7 +222,7 @@
 
 WideString WideStringFromFPDFWideString(FPDF_WIDESTRING wide_string) {
   return WideString::FromUTF16LE({reinterpret_cast<const uint8_t*>(wide_string),
-                                  WideString::WStringLength(wide_string) * 2});
+                                  FPDFWideStringLength(wide_string) * 2});
 }
 
 #ifdef PDF_ENABLE_XFA