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

Use C++20 formatting library for concat()? #938

Open
jtv opened this issue Jan 20, 2025 · 4 comments
Open

Use C++20 formatting library for concat()? #938

jtv opened this issue Jan 20, 2025 · 4 comments
Labels

Comments

@jtv
Copy link
Owner

jtv commented Jan 20, 2025

We now have a string formatting library, which should be exceedingly efficient at concatenating strings for exception messages and such.

My only concern really is that I'm not sure that I'd like to have locales applied to non-string items.

@jtv jtv added the 8.0 label Jan 20, 2025
@tt4g
Copy link
Contributor

tt4g commented Jan 20, 2025

If we support a locale, shouldn't we use the same locale as libpq to avoid confusion?

@jtv
Copy link
Owner Author

jtv commented Jan 21, 2025

@tt4g I'd prefer not to, honestly, unless and until we're ready to support translation. Otherwise, numbers in error messages would suddenly come out localised (e.g. "3,000" in some locales but "3.000" in others etc.) but the localised numbers would show up in error messages that are still in the original English.

That said, I would expect the C++ runtime system to pick up the same locale settings as the C runtime in libpq. So if you set LC_CTYPE or LC_TIME or LANGUAGE, I would expect that to affect libpq and libpqxx in the same way out of the box.

@tt4g
Copy link
Contributor

tt4g commented Jan 21, 2025

I thought you wanted to localize the numeric format in error messages (you want to avoid that).
As far as I know, std::format is not affected by locale unless you specify the L option: https://en.cppreference.com/w/cpp/utility/format/spec
It is safe to use std::format for string concatenation, since it is not localized unless this option is used.

@jtv
Copy link
Owner Author

jtv commented Jan 21, 2025

That's good news. Thanks @tt4g.

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

No branches or pull requests

2 participants