Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to write with a single byte character encoding?
    primarykey
    data
    text
    <p>I have a webservice that returns the config file to a low level hardware device. The manufacturer of this device tells me he only supports single byte charactersets for this config file.</p> <p>On <a href="http://en.wikipedia.org/wiki/SBCS" rel="noreferrer">this wiki page</a> I found out that the following should be single byte character sets:</p> <ul> <li>ISO 8859</li> <li>ISO/IEC 646 (I could not find this one <a href="http://msdn.microsoft.com/en-us/library/86hf4sb8" rel="noreferrer">here</a>)</li> <li>various Microsoft/IBM code pages</li> </ul> <p>But when I call Encoding.GetMaxByteCount(1) on these character sets it always returns 2.</p> <p>I also tried various other encodings (for instance IBM437), but GetMaxByteCount also returns 2 for other character sets.</p> <p>The method Endoding.IsSingleByte seems unreliable <a href="http://msdn.microsoft.com/en-us/library/system.text.encoding.issinglebyte" rel="noreferrer">according to this</a></p> <blockquote> <p>You should be careful in what your application does with the value for IsSingleByte. An assumption of how an Encoding will proceed may still be wrong. For example, Windows-1252 has a value of true for Encoding.IsSingleByte, but Encoding.GetMaxByteCount(1) returns 2. This is because the method considers potential leftover surrogates from a previous decoder operation.</p> </blockquote> <p>Also the method Encoding.GetMaxByteCount has some of the same issues <a href="http://msdn.microsoft.com/en-us/library/system.text.encoding.getmaxbytecount#Y1128" rel="noreferrer">according to this</a></p> <blockquote> <p>Note that GetMaxByteCount considers potential leftover surrogates from a previous decoder operation. Because of the decoder, passing a value of 1 to the method retrieves 2 for a single-byte encoding, such as ASCII. Your application should use the IsSingleByte property if this information is necessary.</p> </blockquote> <p>Because of this I am not sure anymore on what to use.</p> <p><a href="http://www.joelonsoftware.com/articles/Unicode.html" rel="noreferrer">Further reading</a>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload