Posts

Showing posts with the label byte

If a byte is 192 or any other value, is there a way to show how it is made up of its individual bit values?

If a byte is 192 or any other value, is there a way to show how it is made up of its individual bit values? For example, If a byte is 192, I know this will be 128 + 64 = 192 Is there a way in CSharp to list the values that make up the byte so they can be printed or used elsewhere? Thanks "Yes, that's possible" and "What code has been tried / how is it not working?" There are plenty of questions/answers already on the topic.. – user2864740 Jun 29 at 7:10 2 Answers 2 Sample code: int V = 192; int B = 1; for (int i=0; i<8; i++) { if (V&0x01 == 1) { // Use B any way you like } V/=2; B*=2; } Try following : static string ToBinary(int input) { string binary = ...

How to print the text right aligned in a Bluetooth POS Printer?

How to print the text right aligned in a Bluetooth POS Printer? I have been trying to do a POS app in android where I am printing the receipt on a Bluetooth printer connected to the app. I am able to print 'large', 'small' and QR code with the HOINSDK provided with the device and also I am able to align then 'left' and 'centre' but unable to align it to the 'right'. Any help is appreciated. Below are the codes for respective things: //For Large Text cmd[0] = 27; cmd[1] = 97; cmd[2] &= 0xEF; mService.write(cmd); mService.sendMessage("" + large_txt.getText().toString(), "GBK"); //For Small Text cmd[0] = 0x1b; cmd[1] = 0x21; cmd[2] &= 0xEF; mService.write(cmd); mService.sendMessage("" + small_txt.getText().toString(), "GBK"); //For Cent...