Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: int2str -> std::to_string #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sesky4
Copy link
Contributor

@sesky4 sesky4 commented Nov 11, 2024

stringstream 会受到 locale 的影响,该函数被 X-TC-Timestamp 用到

#include <iostream>
#include <string>
#include <sstream>

std::string int2str(int64_t n) {
    std::stringstream ss;
    ss << n;
    return ss.str();
}

int main() {
    std::locale::global(std::locale("en_US.UTF-8"));

    std::cout << int2str(1234) << std::endl;
    std::cout << std::to_string(1234) << std::endl;

    return 0;
}

output:

1,234
1234

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant