'Translating String From ASCII to IBM037 Java Vs Csharp

I am trying to convert A simple Ascii String to EBCIDIC , however i am noticing differences between java C# byte values. Below is C# and java sample code. I have tried several Chars and i see wide difference on each language Byte code

 using System;
 using System.Text;

 public class Program {
   public static void Main(){
     string s = "B";
     Encoding ebcdic = Encoding.GetEncoding(37);//IBM037 encoding
     byte[] asciiBt = Encoding.ASCII.GetBytes(s);
     byte[] ebcdicBytes = Encoding.Convert(Encoding.ASCII, ebcdic, asciiBt);

 foreach(byte b in ebcdicBytes) {
   Console.WriteLine(b);//194 is written to console
 };   } }

On comparing with similar java Code

public class Example{
   public static void main(String args[]) throws Exception{
  String s = "B";
  byte arr[] = s.getBytes("IBM037");
  for (byte x: arr){
     System.out.println(x);//-62 to console
  }}}

Can some one Guide me why the same Charset in 2 different Languages is Writing Different byte Value



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source