Skip to content

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

Open
@F1F88

Description

@F1F88

Prerequisites

  • 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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Buggeneral bugs; can be anything

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions