Rewrite the C# code to make it more extensible.
Extract a function calling the helper with arbitrary arguments.
Work around the fact that Emacs uses legacy codepage-based APIs.