-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
proposal: x/text: expose MIBenum via identifier package #47577
Comments
CC @mpvl |
In what context do you need to look up an encoding by MIBenum? |
This proposal has been added to the active column of the proposals project |
@rsc Not so much for look-up, but rather for storage - storing a number is much more compact. |
What is the exact API you are proposing? What packages would change and how? |
ping @rykov; what API are you suggesting? |
@rsc Sorry for the delay. I've prototyped the proposal in golang/text#30 |
The new API is
But identifier is an internal package. We would need to export MIB from some package (probably not all of identifier). |
@rsc Right. I'm only exporting |
It's very difficult to document those as aliases. We'd need to find some conversion back and forth to hide the existence of the internal package. Any ideas? |
@rsc I don't fully understand: are you suggesting creating two separate types to wrap the internal ones, or do you think that moving the two types out of the internal package into the public package is the better way? |
I looked some more at these packages. I think if we were going to add this API we would want to move x/text/encoding/internal/identifier to x/text/encoding/identifier first. I am not sure whether we should do that though. |
I can try exposing a minimal API via |
@mpvl and I talked about this. We spent a while trying to figure out where to define the MIB type, and we ended up back at "why is this necessary?" When I asked earlier the answer was "Not so much for look-up, but rather for storage - storing a number is much more compact." It seems like if you just need a mapping from name to compact form for storage, it would be easy to define a local one instead of reusing the MIB numbers, which suggests we shouldn't make any API changes here - the justification is not strong enough. |
Based on the discussion above, this proposal seems like a likely decline. |
@rsc We've taken a different direction for text encoding in our project, so we no longer needs this feature. However, my 2¢: given that MIBenum is part of the standard, I disagree that the solution is to keep the mapping internal, and have a consumer of this library reimplement their own equivalent local mapping. |
No change in consensus, so declined. |
I am having trouble finding a way to store and look-up a specific encoding by MIBenum. It would be much more convenient and compact to have access to the MIBenum, rather than using a string name. I would like to start a discussion about exposing MIBenum via the
ID()
method forEncoding
by movingidentifier.Interface
,identifier.MIB
, out of aninternal
package, as well as exposingFindMIB
forianaindex.Index
.MIB enum is part of the IANA standard as described here:
https://www.iana.org/assignments/character-sets/character-sets.xhtml
The text was updated successfully, but these errors were encountered: