2 ms·
I think the top answer in your example is highly misleading and deserves to have the caveats highlighted more clearly even though it's not "wrong". It is saying
by shawnz 6y ago
I think the top answer in your example is highly misleading and deserves to have the caveats highlighted more clearly even though it's not "wrong". It is saying, "you don't need to worry about encoding", but really the point it is proving is "if you just use ONLY toCharArray and BlockCopy on ONLY one system and framework version then you can be sure they always use the same encoding as one another, so in that situation you don't need to worry".
So, the solution works, but only in specific situations which are not clearly explained and might be totally unrelated from OP's situation, and furthermore it doesn't really address the second part of OP's question "why take encoding into consideration?" I wouldn't necessarily call the problems with that answer just "XY pushback".