fork download
  1. using static System.Console;
  2. using System.Text;
  3.  
  4. public class Program {
  5. public static void Main() => WriteLine(ASCII_binary("teste"));
  6. public static string ASCII_binary(string texto) {
  7. var converted = "";
  8. byte[] byteArray = Encoding.ASCII.GetBytes(texto);
  9. for (var i = 0; i < byteArray.Length; i++) {
  10. Write((char)byteArray[i]);
  11. for (var j = 0; j < 8; j++) {
  12. Write($" ({byteArray[i]} - {(byteArray[i] & 0x80)} - {((byteArray[i] & 0x80) > 0 ? "1" : "0")})");
  13. converted += (byteArray[i] & 0x80) > 0 ? "1" : "0";
  14. byteArray[i] <<= 1;
  15. }
  16. WriteLine();
  17. }
  18. return converted;
  19. }
  20. }
  21.  
  22. //https://pt.stackoverflow.com/q/101050/101
Success #stdin #stdout 0.02s 16148KB
stdin
Standard input is empty
stdout
t (116 - 0 - 0) (232 - 128 - 1) (208 - 128 - 1) (160 - 128 - 1) (64 - 0 - 0) (128 - 128 - 1) (0 - 0 - 0) (0 - 0 - 0)
e (101 - 0 - 0) (202 - 128 - 1) (148 - 128 - 1) (40 - 0 - 0) (80 - 0 - 0) (160 - 128 - 1) (64 - 0 - 0) (128 - 128 - 1)
s (115 - 0 - 0) (230 - 128 - 1) (204 - 128 - 1) (152 - 128 - 1) (48 - 0 - 0) (96 - 0 - 0) (192 - 128 - 1) (128 - 128 - 1)
t (116 - 0 - 0) (232 - 128 - 1) (208 - 128 - 1) (160 - 128 - 1) (64 - 0 - 0) (128 - 128 - 1) (0 - 0 - 0) (0 - 0 - 0)
e (101 - 0 - 0) (202 - 128 - 1) (148 - 128 - 1) (40 - 0 - 0) (80 - 0 - 0) (160 - 128 - 1) (64 - 0 - 0) (128 - 128 - 1)
0111010001100101011100110111010001100101