I have a string which is pulled from a SQL database using EF, through a view. string sample is "mystring" with length of 8. When I compare this string to "mystring" I am getting "false".
I've converted the string to (byte) array:
("mystring").Select(m=>(byte)m).ToArray();
I see I have an extra char with keycode "15" at the end of the array.
I've looked anywhere what is the keycode '15' and I didn't see it in the keycode tables.
My questions are:
What is the char represented by "15" when converted to byte?
Why is it added to the string? (it is a string that my users can change with admin screen)
Added: it doesn't happen every time, only with (for now) one string.
Edit: I copy paste part of that string to Immediate window, to check for Length and I get Length = 2
This is the string:
"a".Length
2
The GetBytes in UF8 of this string is:
{byte[4]}
[0]: 97
[1]: 226
[2]: 128
[3]: 143
The int value of the 2nd char (which does not exist in my eyes) is:
var intvalue = (int)test[1];
8207
Update: Now when I do inspect element on that "a" string i copy pasted before I see "a&rlm" --> what is it and how I get rid of it?
Looking at the string you have in your question in the HTML source it is written as
a‏
. A quick google shows that rlm is the left to right mark which is unicode U+200F (http://en.wikipedia.org/wiki/Right-to-left_mark).Combine this with other people's observation that casting to byte leaves only the final byte explains why you are getting 0F = 15 as your byte number.
Where this is coming from is something for you to investigate but I would imagine it comes from the original user input (ie the user is inputting text right to left).