Skip to content

Improve writeCodePointValue KDoc #314

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

Merged
merged 1 commit into from
May 7, 2024
Merged

Improve writeCodePointValue KDoc #314

merged 1 commit into from
May 7, 2024

Conversation

fzhinkin
Copy link
Collaborator

@fzhinkin fzhinkin commented May 7, 2024

Follow up to #308

@fzhinkin fzhinkin merged commit f36dd27 into develop May 7, 2024
1 check passed
@fzhinkin fzhinkin deleted the 307-ammendments branch May 7, 2024 10:33
@@ -130,6 +130,9 @@ internal fun String.utf8Size(startIndex: Int = 0, endIndex: Int = length): Long
* Without such a conversion, data written to a [Sink] can not be converted back
* to a string from which a surrogate pair was retrieved.
*
* More specifically, all code points mapping to UTF-16 surrogates (`U+d800`..`U+dfff`)
* will be written as `?` characters (`U+0063`).
Copy link
Member

Choose a reason for hiding this comment

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

Is this JVM-only behavior or common one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Currently, it's a common one

Copy link
Member

Choose a reason for hiding this comment

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

This makes it inconsistent with String.encodeToByteArray where the replacement is unspecified, but different.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

encodeToByteArray call on a string with a low surrogate only results in a byte array containing ?: https://pl.kotl.in/uFX3YULin

@@ -130,6 +130,9 @@ internal fun String.utf8Size(startIndex: Int = 0, endIndex: Int = length): Long
* Without such a conversion, data written to a [Sink] can not be converted back
* to a string from which a surrogate pair was retrieved.
*
* More specifically, all code points mapping to UTF-16 surrogates (`U+d800`..`U+dfff`)
* will be written as `?` characters (`U+0063`).
*
* @param codePoint the codePoint to be written.
*
* @throws IllegalStateException when the sink is closed.
Copy link
Member

Choose a reason for hiding this comment

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

Makes sense to document that IllegalArgumentException can be thrown.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

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