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

ICU-22954 USet C++ iter samples no UnicodeString #3316

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

Conversation

markusicu
Copy link
Member

... to make the sample code work without U_SHOW_CPLUSPLUS_API as discussed in #3295 (comment)

I am also moving the non-sample code above the commented-out sample code, for clarity.

Checklist

  • Required: Issue filed: ICU-22954
  • Required: The PR title must be prefixed with a JIRA Issue number. Example: "ICU-1234 Fix xyz"
  • Required: The PR description must include the link to the Jira Issue, for example by completing the URL in the first checklist item
  • Required: Each commit message must be prefixed with a JIRA Issue number. Example: "ICU-1234 Fix xyz"
  • Issue accepted (done by Technical Committee after discussion)
  • Tests included, if applicable
  • API docs and/or User Guide docs changed or added, if applicable

* printf("uset.string length %ld \"%s\"\n", (long)s.length(), us.toUTF8String(u8).c_str());
* int32_t len32 = s.length();
* char utf8[200];
* u_strToUTF8WithSub(utf8, 199, nullptr, s.data(), len32, 0xFFFD, nullptr, errorCode);
Copy link
Member

@roubert roubert Dec 27, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Considering how many of these Frank has fixed just in the past few years, to correct off-by-one errors and hardcoded lengths forgotten when buffer sizes were changed, I think it's a really good idea to use UPRV_LENGTHOF or sizeof expressions even in commented-out sample code.

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.

3 participants