-
Notifications
You must be signed in to change notification settings - Fork 4.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: Base64/128 Variable Length Quantity (VLQ) in System.Convert #15237
Comments
I don't like stuffing more encodings into the I don't see much benefit in unifying Base 64 VLQ and Base 128 VLQ implementations. Base 128 VLQ seems to be a binary 8 bit encoding whereas Base 64 VLQ is a text encoding. The names suggest that they're the same encoding with 1 bit difference, but the difference is actually 2 bits. I'd prefer a separate assembly for source map handling which includes Base 64 VLQ encoding. You included separator handling in your code ( |
Thanks for the input @CodesInChaos.
In which case VLQ variant can probably share the same class; as with certain flexible implementation, redundancies can be avoided in achieving both fixed and variable length quantities. The bit which distinguish between source-map V
Note that the only part of V3 source-map template I referred here is IMO, while "source-map" as a library implementation should be a separate assembly, there is room for FLQ & VLQ encodings to co-exists in .NET Core; and depending on the flexibility of implementation the source-map assembly implementer would be able to consume .NET Core's Base64VLQ implementation as is. |
@AlexGhiondea, I am busy with other projects at the moment. This API is on my TODO list. I will try to start working on it as I get some free time. Thanks for mentioning CoreFXLab repo. That certainly seems like the best place to start for new APIs. |
@am11 sounds great! Looking forward to seeing what you come up with! |
Concept:
System.Convert
currently resides in CoreCLR repo: https://github.com/dotnet/coreclr/../System/Convert.cs. The class has number of methodsToBase64*
andFromBase64*
with various signatures. The base64 encoding has 8-bit fixed length.The are many applications of variable length base64 encoding; Variable Length Quantity (VLQ). IMO, one of the most popular application of B64 VLQ is in V3 source maps; which is used by browsers, editors, trans-compilers etc. to obtain source-to-source mappings in trans-compilation scenarios. For instance; CoffeeScript, Less, Sass, Stylus, SweetJS and TypeScript are languages, that compile into CSS or JavaScript. Today, the developer tools in all major browsers are capable of mapping generated source to original by the virtue of source-maps. Additionally, Base128 VLQ has applications in media formats, such as MIDI, XMF etc. [1]
Proposed API:
Working Example:
We implemented sourcemap encoding and decoding in WE2013:
https://github.com/madskristensen/WebEssentials2013/../Base64VLQ.cs, inspired by Mozilla's JavaScript implementation: https://github.com/mozilla/source-map.
The text was updated successfully, but these errors were encountered: