Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.3 KiB

  1. #include "npcommon.h"
  2. /* In a DBCS build, the Win32 CharUpper API will uppercase double-byte
  3. * Romanji characters, but many low-level network components such as
  4. * IFSMGR (and NetWare servers!) do not uppercase any double-byte
  5. * characters. So we have to have our own function which avoids them.
  6. *
  7. * This could be implemented by just calling CharUpper on each character,
  8. * but the NLS APIs have a fair amount of overhead to them, so calling
  9. * into the NLS subsystem as few times as possible is desirable.
  10. */
  11. LPSTR WINAPI struprf(LPSTR lpString)
  12. {
  13. if (!::fDBCSEnabled)
  14. return CharUpper(lpString);
  15. LPSTR pchStart = lpString;
  16. while (*pchStart != '\0') {
  17. // Skip any double-byte characters that may be here.
  18. // Don't need to check for end of string in the loop because
  19. // the null terminator is not a DBCS lead byte.
  20. while (IsDBCSLeadByte(*pchStart))
  21. pchStart += 2; /* skip double-byte chars */
  22. if (*pchStart == '\0')
  23. break; /* no more SBCs to uppercase */
  24. // Find the end of this range of single-byte characters, and
  25. // uppercase them.
  26. LPSTR pchEnd = pchStart + 1;
  27. while (*pchEnd && !IsDBCSLeadByte(*pchEnd))
  28. pchEnd++; /* count single-byte chars */
  29. CharUpperBuff(pchStart, (int)(pchEnd-pchStart));
  30. pchStart = pchEnd;
  31. }
  32. return lpString;
  33. }