Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: minor edits

...

Noncompliant Code Example (setlocale())

In this noncompliant code example, the function utf8_to_ucs() attempts to convert a sequence of UTF-8 characters to the Universal Character Set (UCS). It first invokes setlocale() to set the global locale to "en_US.UTF-8" but does not check for failure. The setlocale() function will fail by returning a null pointer, for example, when the locale is not installed. ( The function may fail for other reasons as well, such as the lack of resources.)   Depending on the sequence of characters pointed to by utf8, the subsequent call to mbstowcs() may fail or result in the function storing an unexpected sequence of wide characters in the supplied buffer ucs.

...