Codereview request for 4153167: separate between ANSI and OEM code pages on Windows
Alan Bateman
Alan.Bateman at oracle.com
Fri Feb 17 15:48:03 UTC 2012
On 17/02/2012 15:35, Tom Hawtin wrote:
>
> Although it's in some sense safe in this case, you might get a grumble
> about introducing a new sprintf.
>
> +static char* getConsoleEncoding()
> +{
> + char* buf = malloc(16);
> + int cp = GetConsoleCP();
> + if (cp >= 874 && cp <= 950)
> + sprintf(buf, "ms%d", cp);
> + else
> + sprintf(buf, "cp%d", cp);
> + return buf;
> +}
>
> Tom
You're right, we should avoid sprintf. It's not an issue here but will
be flagged by tools that do static analysis on the source.
-Alan.
More information about the core-libs-dev
mailing list