-
Notifications
You must be signed in to change notification settings - Fork 60
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
Rename string read/writeUtf8 methods #156
Rename string read/writeUtf8 methods #156
Conversation
Question regarding
What is better:
Im fine with both variants, just wanted to ask :) |
I didn't make it optional because there was already a function for writing UTF8 strings. And now, when it shares the name with Charset-based functions, we can encourage users to use a common function for UTF-8 strings instead of a JVM-specific one by requiring explicit charset value in the latter. Possible future support for our own charsets in IO library is a great argument for supplying default value for the
It looks strange to have a charset as a first parameter there. If we writing a string, then the string should be the first parameter and all other options controlling how it'll be written should follow it, not proceed. |
- Implemented basic ByteString API - Supported ByteString in kotlinx-io - Changed ByteString::toString to always return full string representation - Restructured unsafe API, move utf-8 conversion to base module - Enabled JS target in bytestring module - Made the code BCE-friendly - Renamed readUtf8/writeUtf8 to readString/writeString (#156): Currently, we use ByteString.decodeToString and String.encodeToByteString as names for conversion methods between String and ByteString, where non-parameterized functions convert to/from UTF-8, and JVM-specific extensions accept Charset. At the same time, the core module uses different naming for methods reading/writing UTF-8 string and methods reading/writing strings using specific Charset: - Source.readUtf8/Sink.writeUtf8 to work with UTF-8 strings - Source.readString/Sink.writeString to work with strings using the given Charset on JVM. The naming is inconsistent and it seems reasonable to unify read/write methods naming with what we have for ByteString. We can use readString/writeString w/o charset for UTF-8 strings (as these are treated as default in the library) and same-titled JVM-specific extensions accepting a Charset.
Closes #155; see the ticket for the rationale.