Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

.net

char

ascii

I am working with string delimiters and one of them is « or 174. However, when I step through my code it looks like this in the debugger, ®, which is 0174. See here for Codes.

This is how I'm doing it in code for reference:

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

like image 831
Refracted Paladin Avatar asked Feb 15 '23 00:02

Refracted Paladin


1 Answers

It is all about character encoding. 174 (AE in hex) is ® in Unicode, which is used internally in string by default. But it is « in Extended ASCII code.

Please refer this difference in article you've provided:

Inserting ASCII characters

To insert an ASCII character, press and hold down ALT while typing the character code. For example, to insert the degree (º) symbol, press and hold down ALT while typing 0176 on the numeric keypad.

Inserting Unicode characters

To insert a Unicode character, type the character code, press ALT, and then press X. For example, to type a dollar symbol ($), type 0024, press ALT, and then press X.

like image 197
Konrad Kokosa Avatar answered Feb 27 '23 17:02

Konrad Kokosa