I am writing a windows application. am facing problem in converting Extended ASCII[128-256] to its decimal equivalent.
when i receive the extended ASCII say for example "Œ" from a jar file, it comes into C# application like this : �.
Can i know how to convert this to its decimal equivalent [i.e] 140.
string textToConvert = "Œ";
Encoding iso8859 = Encoding.GetEncoding("iso-8859-1");
Encoding unicode = Encoding.Unicode;
byte[] srcTextBytes = iso8859.GetBytes(textToConvert);
byte[] destTextBytes = Encoding.Convert(iso8859,unicode, srcTextBytes);
char[] destChars = new char[unicode.GetCharCount(destTextBytes, 0, destTextBytes.Length)];
unicode.GetChars(destTextBytes, 0, destTextBytes.Length, destChars, 0);
System.String szchar = new System.String(destChars);
MessageBox.Show(szchar);
Please help me. How should i proceed??
I think you are looking for something like this
String str="œ";
var bytes = Encoding.GetEncoding("Windows-1252").GetBytes(s);
string binStr = string.Join("", bytes.Select(b => Convert.ToString(b, 2)));
int decimalEquivalent=Convert.ToInt32(binStr,2);
Console.WriteLine(decimalEquivalent);
this is working for ASCII [128-255]