(Char) 174, returning the value of (Char) 0174, why?

I work with string delimiters, and one of them is "or 174. However, when I look at my code, it looks like this in the debugger ยฎ, which is equal 0174. See here for the codes.

Here is how I do it in the code for reference:

string fvDelimiter = ((char)174).ToString();

+4
source share
3 answers

It's all about character encoding. 174( AEin hexadecimal format) is Unicode , which is used internally by default string. But this is ยซin Extended ASCII code .

Please check out this difference in the article you provided:

ASCII

ASCII, ALT . , (ยบ), ALT 0176 .

, , ALT, X. , ($), 0024, ALT, X.

+6

, , . Windows " ", . , "" Calibri 171.

+1

, char # unicode, 0174, ASCII, 174

, ,

            var chrs = System.Text.Encoding.ASCII.GetChars( new byte[]{0174});
            var chrsUtf = System.Text.Encoding.UTF8.GetChars(new byte[] { 0174 });
            var chrsUnicode = System.Text.Encoding.Unicode.GetChars(new byte[] { 0174 }); 
            Debug.WriteLine(chrs[0].ToString());
            Debug.WriteLine(chrsUtf[0].ToString());
            Debug.WriteLine(chrsUnicode[0].ToString());
+1
source

All Articles