Skip to content

Enhance the string encoding interoperability. #11

Description

@JamesMenetrey

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions