Subject: Home Remodeling Trend

From: Bathing Safety Standards <[email-masked]>
Date: Tue, 27 May 2014 11:54:20 -0700

Safety Standard Newsletter
published - May 27, 2014
===========================

Bathing should be a soothing experience, regardless of age or mobility challenges.

When it comes to your daily routine, you should never have to choose between comfort, 
safety and independenceand now, with Walk-In Tubs... you dont have to.

View Safety Features Here: / http://www.capfourfan.com/home/safety/improvement.index

We are happy to have introduces you to a growing trend in bathroom remodeling.

- 

- modification requests directed to - Update Notice Messages
1 1 8-Kecks Ln-Ruff Dale, PA 15679 or http://www.capfourfan.com/65sf/h6t6r.wrg5638

artbristol: If they can't be bothered to read the answer (or the other answers...), then I'm sorry, then there's no better way for me to communicate with them. I generally opt for answering the OP rather than trying to guess what others might do with my answer -- the OP has the right to know, and just because someone might abuse a knife doesn't mean we need to hide all knives in the world for ourselves. Though if you disagree that's fine too.   Mehrdad Jun 15 '12 at 14:04   	
The question was asked 3 years ago, and is totally ambiguous. You have no evidence of how OP was going to use the bytes. Other people will have the exact same question, but will be planning to use the bytes in a situation where encoding matters, and your answer will be dead wrong in that case.   artbristol Jun 15 '12 at 14:25  	
Well, the way I think about it is: I'm not a judge. I don't ask for "evidence" from the OP to try to prove his case before I answer him (contrary to what others might try to do). He clearly said, "Can't I simply get what bytes the string has been stored in? Why this dependency on encoding?", to which my answer is 100% accurate, more than the others on this page IMO. And IMO he's understood the caveats by now. Also, the fact that the answer was from 3 years ago is irrelevant. But again, if you'd rather ask for "evidence" first, then that's your style, and feel free to keep the downvote..   Mehrdad Jun 15 '12 at 14:32 
When the questioner says that, you should interpret it as 'I don't understand encodings, bytes, and characters'. You are taking it too literally.   artbristol Jun 15 '12 at 14:37
@artbristol: I definitely don't agree about how you think I "should interpret" questions on SO, but thanks for letting me know.   Mehrdad Jun 15 '12 at 14:48 But, why should encoding be taken into consideration? Why can't I simply get the bytes without having to see what encoding is being used? Even if it were required, shouldn't the String object itself know what encoding is being used and simply dump what is in memory?   Agnel Kurian Jan
A .NET strings are always encoded as Unicode. So use System.Text.Encoding.Unicode.GetBytes(); to get the set of bytes that .NET would using to represent the characters. However why would you want that? I recommend UTF-8 especially when most characters are in the western latin set.   AnthonyWJones Jan 23 '09 at 14:33
There's also System.Text.Encoding.Default   Joel Coehoorn Jan 23 '09 at 15:39
Also: the exact bytes used internally in the string don't matter if the system that retrieves them doesn't handle that encoding or handles it as the wrong encoding. If it's all within .Net, why convert to an array of bytes at all. Otherwise, it's better to be explicit with your encoding   Joel Coehoorn Jan 23 '09 at 15:42
@Joel, Be careful with System.Text.Encoding.Default as it could be different on each machine it is run. That's why it's recommended to always specify an encoding, such as UTF-8.   Ash Jan 28 '10 at 9:01
1 character could be represented by 1 or more bytes" I agree. I just want those bytes regardless of what encoding the string is in. The only way a string can be stored in memory is in bytes. Even characters are stored as 1 or more bytes. I merely want to get my hands on them bytes.   Agnel Kurian Jan 23 '09 at 14:07
You don't need the encodings unless you (or someone else) actually intend(s) to interpret the data, instead of treating it as a generic "block of bytes". For things like compression, encryption, etc., worrying about the encoding is meaningless. See my answer for a way to do this without worrying about the encoding.   Mehrdad Apr 30 '12 at 7:54@Mehrdad - Totally, but the original question, as stated when I initially answered, didn't caveat what OP was going to happen with those bytes after they'd converted them, and for future searchers the information around that is pertinent - this is covered by Joel's answer quite nicely - and as you state within your answer: provided you stick within the .NET world, and use your methods to convert to/from, you're happy. As soon as you step outside of that, encoding will matter.  	
You don't need the encodings unless you (or someone else) actually intend(s) to interpret the data, instead of treating it as a generic "block of bytes". For things like compression, encryption, etc., worrying about the encoding is meaningless. See my answer for a way to do this without worrying about the encoding. (I might have given a -1 for saying you need to worry about encodings when you don't, but I'm not feeling particularly mean today. :P)   Mehrdad Apr 30 '12 at 7:55 Good discussion, sometimes I need one of the above alternatives. But also looks like: "One fool can ask more than seven wise men can answer" :-)   Roland Mar 26 '13 at 14:49
1	 Don't surrogates have to appear in pairs to form valid code points? If that's the case, I can understand why the data would be mangled.   dtanders Jun 14 '12 at 14:27
@dtanders Yes,that's my thoughts too, they have to appear in pairs, unpaired surrogate characters just happen if you deliberately put them on string and make them unpaired. What I don't know is why other devs keep on harping that we should use encoding-aware approach instead, as they deemed the serialization approach(my answer,which was an accepted answer for more than 3 years) doesn't keep the unpaired surrogate character intact. But they forgot to check that their encoding-aware solutions doesn't keep the unpaired surrogate character too,the irony Allow me to clarify: An encoding has been used to translate "hello world" to physical bytes. Since the string is stored on my computer, I am sure that it must be stored in bytes. I merely want to access those bytes to save them on disk or for any other reason. I do not want to interpret these bytes. Since I do not want to interpret these bytes, the need for an encoding at this point is as misplaced as requiring a phone line to call printf
 .   Agnel Kurian Jul 16 '09 at 15:30
But again, there is no concept of text-to-physical-bytes-translation unless yo use an encoding. Sure, the compiler stores the strings somehow in memory - but it is just using an internal encoding, which you (or anyone except the compiler developer) do not know. So, whatever you do, you need an encoding to get physical bytes from a string.   Konamiman Jul 22 '09 at 8: 	  	
@Agnel Kurian: It is of course true, that a string has a bunch of bytes somewhere that store its content (UTF-16 afair). But there is a good reason to prevent you from accessing it: strings are immutable and if you could obtain the internal byte[] array, you could modify it, too. This breaks immutability, which is vital because multiple strings may share the same data. Using an UTF-16 encoding to get the string will probably just copy the data out.   ollb May 14 '11 at 0:06  Michael Buen Jun 14 '12 at 23:23 
If there's a serialization library that uses System.Buffer.BlockCopy internally, all encoding-advocacy folks' arguments will be moodad: The GetString method is and interpretation of the output of the GetBytes method. This is why you have to worry to use the same encoding in both methods.   chiccodoro Jul 17 '13 at 7:57