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

.c_str() on an empty localized string returns NULL/nullptr #26446

Open
bradcray opened this issue Dec 20, 2024 · 0 comments
Open

.c_str() on an empty localized string returns NULL/nullptr #26446

bradcray opened this issue Dec 20, 2024 · 0 comments

Comments

@bradcray
Copy link
Member

When using c_str() on a .localize()d empty string, we seem to get NULL out rather than an empty string (ATO). For example, the following program:

use CTypes, IO, IO.FormattedIO;

extern proc printf(fmt...);

var emptyStr: string = "";
var aStr: string = "a";

printf("%d %s %s\n", here.id, aStr.c_str(), emptyStr.c_str());
for loc in Locales do on loc {
  printf("%d %s %s\n", here.id, aStr.localize().c_str(), emptyStr.localize().c_str());
}

prints:

0 a
0 a (null)
1 a (null)

where the lines after the first indicate a bad interaction between c_str() and localize() (or more likely, a bug in localize()).

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

No branches or pull requests

1 participant