sourcemod icon indicating copy to clipboard operation
sourcemod copied to clipboard

[Bug]: Format specifier "%s" is always left-aligned

Open F1F88 opened this issue 6 months ago • 0 comments

Prerequisites

  • [x] I have checked that my issue doesn't exist yet in the issue tracker

Operating System and Version

Windows 11 24H2

Game / AppID and Version

NMRIH version 1.14.2

SourceMod Version

1.12.0-git7197

Metamod:Source Version

1.12.0-git1219

Version Verification

  • [x] I have updated SourceMod to the latest version and the issue persists
  • [x] I have updated SourceMod to the latest snapshot and the issue persists
  • [x] I have updated Metamod:Source to the latest snapshot and the issue persists

Updated SourceMod Version

1.13.0-git7241

Updated Metamod:Source Version

2.0.0-1350

Description

The format specifier "%s" is always left-aligned and does not support padding with '0'.

This is contrary to the description in the wiki - Format Class Functions

Steps to Reproduce

#include <sourcemod>
#include <sdktools>

public void OnPluginStart()
{
    char[] text = "1234567";

    PrintToServer("|%s|", text);
    PrintToServer("|%10s|", text);
    PrintToServer("|%-10s|", text);
    PrintToServer("|%010s|", text);
    PrintToServer("|%-010s|", text);
}

Relevant Log Output

Expected Output (according to wiki):

|1234567|
|   1234567|
|1234567   |
|0001234567|
|1234567000|

Actual Output:

|1234567|
|1234567   |
|1234567   |
|1234567   |
|1234567   |

In addition, "%L", "%N", "%E" (#2330), and "%f" with a value of NaN or Inf (#2324) all use AddString, so the same problem exists.

~~Related to discord link~~

F1F88 avatar Jun 02 '25 08:06 F1F88