I didn’t really look deeper into the library so I can’t make stronger recommendations. That said, based on this discussion, I see the following options:
- Generate all the code for all encodings at compile time
In this approach, we’d be able to invoke something like Codepagex.CP1251.from_string(...)
I believe this is the most straightforward solution, and it’s the one I’d try first. Possible blocker is that this might increase the first compilation time, and cause a significant disk/memory usage overhead. I think it should be tried out, and the overhead should be measured.
- The
usesolution I originally proposed
In this approach, the client can cherry pick the encodings it needs, so we generate the minimal amount of code. The interface is a bit clumsier, but it resolves possible blockers from #1.
There are some other options that could be considered, such as deferring the decision to runtime, or splitting the library into multiple libraries, but for a few reasons I’m not inclined to try out those (again, I didn’t study the lib code in details, so my assumptions might be wrong).






















