c# - How can i encode each string? -
At the end of the loop I am getting a list and I look in each index inside:
This is when the text is in encoding code in Hebrew: 65001
System.Text.Encoding.GetEncoding (65001) Public list & lt; String & gt; GetResponsers {String Content} {List & lt; String & gt; Thread list = new list & lt; String & gt; (); Int f = 0; Int startPos = 0; While (true) {string firstTag = " gt; // string first tag = ";>"; String end tag = "& amp; n"; // string endtags = ": that"; F = contents.IndexOf (first tag, startPos); If (f == -1) {break; } Int G = Content Index (last tag, f); StartPos = G + Last tag. String Regressor = Content Substrings (F + 2, G - F2); ThreadList.Add (responser); } Return thread list; }
How do I implement encoding for each representative?
This method is used after trying to use encoding:
public list & lt; String & gt; GetResponsers {String Content} {List & lt; String & gt; Thread list = new list & lt; String & gt; (); Int f = 0; Int startPos = 0; While (true) {string firstTag = " gt; // string first tag = ";>"; String end tag = "& amp; n"; // string endtags = ": that"; F = contents.IndexOf (first tag, startPos); If (f == -1) {break; } Int G = Content Index (last tag, f); StartPos = G + Last tag. String Regressor = Content Substrings (F + 2, G - F2); Encoding iISO = encoding Gate encoding (65001); Byte [] isoBytes = ISO. Gatesbytes (responsive); String FF = iso.getString (isoBytes); Responder = FF; ThreadList.Add (responser); } Return thread list; }
But it did not change anything.
"it does not change anything" because
encoding iso = Encoding Gate encoding (65001); Byte [] isoBytes = ISO. Gatesbytes (responsive); String FF = iso.GetString (isoBytes)
does nothing at the end - it's like "Add 10, Delete 10" - there is no change at the end. And there are reciprocal functions when used with the same encoding.
You should apply encoding-decoding to that point where you get the data for the string (because there is nothing wrong or incorrectly encoding due to it being incorrect).
But if the string is already decoded with wrong encoding, you can try to fix the problem by using encoding to get the original bytes and encode it correctly You can use your local encoding for:
byte [] nativebits = encoding.default. Getbytes (mangled STR); String string = encoding Gate encoding (65001). Getstrings (Native Bits);
But this can happen or will not work if the string is used only on the basis of the original encoding.
The best solution is to have some encoding your original web service that basically supports your locality - or it will protect you from any problem with encoding-decoding.
PS : Also keep in mind that if the encoding is different from the encoding of the system, VS Debugger can sometimes be a problem with the correct representation of the string - if you check your string in the debugger The same applies to certain controls and applications.
Comments
Post a Comment