|
I have recently come across a particularly disheartening concept regarding Client/Server interactions, which in general is itself disheartening. The topic concerns Encoding and the methods C# provides for implementing and utilizing Encoding. While the general idea of using Encoding seems simple, the examples and documentation I have found only further my confusion regarding this topic. Firstly I am baffled by what the Get methods do in each of the Encoding classes. The description seems to indicate that, for instance, the GetString method takes a byte array, decodes it using the given Encoding, then returns the decoded string. This, however, is not intuitive as you would hope that the GetString method would simple return a String representation of the Encoded byte array. Perhaps this is what the method does in fact do, but currently I have not discovered the answer. Another particurlary daunting problem is the issue concerning conversion between the different types of data types used when trasnferring data across a network connection. The examples do not provide a clearcut way for doing this, and thus I am still in a state of thorough confusion. Perhaps once I have solved these problems I could then go ahead and implement a new class which aims to ease this process. The class would include, but would not be limited to the following concepts:
Given an array of bytes, there would be methods that would convert this array to a String, char array, or any other basic data types and would allow for the use of an Encoder or not.
A way to take a given string, or array of characters and convert it to either a byte array, string array or char array without Decoding, as well as a method to do so WITH encoding
As I am writing this I realize I do not fully grasp the concept of encoding, and I belive that an array of bytes represents binary data which is not encoded, but I also know there are too many variations and no simple explanation for how to do a simple client/server interaction.
|
|
|
|