Skip to content
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

Enhance the string encoding interoperability. #11

Open
JamesMenetrey opened this issue Nov 7, 2016 · 0 comments
Open

Enhance the string encoding interoperability. #11

JamesMenetrey opened this issue Nov 7, 2016 · 0 comments

Comments

@JamesMenetrey
Copy link
Owner

Background

Currently, strings are read and written using dedicated methods (ReadString/WriteString). While those functions enable the develop to specify the encoding, this is not the case for the Execute methods. Indeed, those methods can be called with arbitrary .NET parameters but there is no way to specify an encoding.

This enhancement addresses this issue by adding a layer of abstraction on .NET strings. A new class, possibly EncodedString, describes a string and an encoding. The dedicated methods for strings will be removed and replaced by the traditional Read/Write methods. Extension methods will helps the developer to encode properly a string.

API DEMO

Before:
s.WriteString(address, text); // UTF8 by default
s.WriteString(address, text, Encoding.Ansi);
p.Execute(callingConvention, text); // Only in UTF8

After:
s.Write(address, text); // UTF8 by default
s.Write(address, text.EncodeAsAnsi());
p.Execute(callingConvention, text.EncodeAsAnsi()); // Handle any encoding

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant