last day (14 days later) » 

12:19 PM
room topic changed to GrawCube assisting: (no tags)
Hey!
 
hey there!
 
Can you get a byte array containing the string?
*strings
Encoding.UTF8.GetBytes(yourString)
 
sure, just one moment
wow, I did this before and they were the same, this time thjey are different, here's the input byte array:
69
108
101
99
116
114
111
110
105
99
32
72
105
103
104
32
80
101
114
102
111
114
109
97
110
99
101
the case value byte array:
239
187
191
69
108
101
99
116
114
111
110
105
99
32
72
105
103
104
32
80
101
114
102
111
114
109
97
110
99
101
how can this be happening?
 
That's the UTF-8 BOM (byte order mark) in the beginning
0xEF,0xBB,0xBF
The byte order mark (BOM) is a Unicode character used to signal the endianness (byte order) of a text file or stream. It is encoded at U+FEFF byte order mark (BOM). BOM use is optional, and, if used, should appear at the start of the text stream. Beyond its specific use as a byte-order indicator, the BOM character may also indicate which of the several Unicode representations the text is encoded in. Because Unicode can be encoded as 16-bit or 32-bit integers, a computer receiving these encodings from arbitrary sources needs to know which byte order the integers are encoded in. The BOM gives the...
How are you obtaining the case value string?
 
Encoding.UTF8.GetBytes("Electronic High Performance")
 
12:29 PM
Ah
 
as opposed to Encoding.UTF8.GetBytes(subTech)
 
I see
new UTF8Encoding(false).GetBytes("Electronic High Performance")
use that instead
the boolean in the constructor tells it to not prepend the BOM
Wait a second
I'm sorry, Encoding.UTF8.GetBytes doesn't prepend the BOM
the BOM character is in your string literal
Place your cursor between the first and second character in "Electronic...."
so between E and l
then tap left with your arrow keys
you'll notice that there's an extra character
 
using the UTF8Encoding I got the same array as the first:
69
108
101
99
116
114
111
110
105
99
32
72
105
103
104
32
80
101
114
102
111
114
109
97
110
99
101
 
Your case label has the BOM in the string literal at the beginning :)
 
I'm not sure I understand..
 
12:36 PM
Okay so
case "Electronic High Performance":
-----^
between " and Electronic
there's an invisible character
remove it :)
 
whaaaat? lol
any suggestions how to ensure I've removed it?
 
err
remove the whole shebang and type it manually without copypasting?
 
I've done that several times but I'll give it another shot
 
you sure?
umm
you said "the case value byte array:"
did you mean that those are the bytes of "case: "Electronic High Performance"" or do you mean you're getting it from the default: case
 
I meant those were the bytes of "Electronic High Performance", which is the case
 
12:40 PM
yeah okay
just....erase this part ["Elec]tronic High Performance
 
so I retype case "Retype value here":, correct>?
 
and type it manually back in
erase the starting quotation mark as well
 
ok, I just did that and it worked and I'm blown away a little. I have done this before
 
:)
 
although, now that I think about it, I may have only replaced the contents inside the quotes
 
12:42 PM
read the link I posted above if you want to learn more
yeah quite possibly
 
wow. thank you so much!
 
the byte-order-mark is a very common stumbling block
here's another case caused by the BOM
you write a file in C#, using Encoding.Unicode or whatever as the StreamWriter's encoding
however, you open it and you see chinese
in that case your text editor has (for some reason) opened the file as UTF-8 instead of UTF-16 or UCS-2
usually it can be fixed by opening your hex editor (if you just want to fix the file real quick), taking a look at the start of the file, and adding 0xFF 0xFE (which is the UTF-16 Little Endian) byte order mark, then saving and closing
your text editor will read those two bytes and realize that it should display the data using UTF-16
If this all seems super duper confusing and you missed everything
even if you understand it, read that article --^
did I already mention that you should read that article?
you should definitely read that article
:o)
 
haha I will certainly have a look at it. Thanks again for your very informative help! We are very appreciative over here! I must digress back to the work at hand but thank you again! You have saved us a lot of time! Have a great day! :)
 
No problem! Have a nice day!
 

last day (14 days later) »