Skip to content

Conversation

@vszakats
Copy link
Member

@vszakats vszakats commented Dec 15, 2025

Add comments to clarify that a terminating null is always present in
the buffers returned to the caller.

The curl APIs win32_idn_to_ascii() or win32_ascii_to_idn() receive
a null-terminated UTF-8 string as input. They first convert it to wide
chars by first asking MultiByteToWideChar() to calculate the length,
by passing -1. This API returns the length with the null char included
(= strlen() + 1), does the conversion, with the output also
null-terminated. IdnTo*() preserve this null character as documented.
Then we pass this null-terminated, fixed-length buffer ito
WideCharToMultiByte(), which keeps preserving the null, ending up in
the buffer returned to the caller.

Refs:
https://learn.microsoft.com/windows/win32/api/stringapiset/nf-stringapiset-multibytetowidechar
https://learn.microsoft.com/windows/win32/api/stringapiset/nf-stringapiset-widechartomultibyte
https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-idntoascii
https://learn.microsoft.com/windows/win32/api/winnls/nf-winnls-idntounicode

WINE source code:
https://gitlab.winehq.org/wine/wine/-/blob/wine-10.20/dlls/kernelbase/locale.c
https://gitlab.winehq.org/wine/wine/-/blob/wine-10.20/dlls/ntdll/locale.c
https://gitlab.winehq.org/wine/wine/-/blob/wine-10.20/dlls/ntdll/locale_private.h

Ref: #19976 (comment)
Follow-up to 6694a42 #19798

@vszakats vszakats added Windows Windows-specific name lookup DNS and related tech labels Dec 15, 2025
@github-actions github-actions bot removed the Windows Windows-specific label Dec 15, 2025
@bagder bagder requested a review from Copilot December 15, 2025 16:01
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@vszakats vszakats changed the title idn: clarify NUL-termination on Windows idn: clarify null-termination on Windows Dec 15, 2025
@vszakats vszakats added Windows Windows-specific documentation labels Dec 16, 2025
@vszakats vszakats closed this in be76b32 Dec 16, 2025
@vszakats vszakats deleted the idnul branch December 16, 2025 15:56
@vszakats
Copy link
Member Author

Thanks for reviewing!

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

Labels

documentation name lookup DNS and related tech Windows Windows-specific

Development

Successfully merging this pull request may close these issues.

3 participants