Dec 7, 2010 Replies: 78 It's occasionally useful to be able to poke around in things as arrays of bytes so this library lets you do it. It can transform arrays of primitive types to and from arrays of bytes with the "endian-ness" of the conversion specified. If you need endian-ness you will either know about it or rather quickly find out. Byte arrays can be transformed to and from a hexadecimal string representation. Strings can be transformed to and from arrays of Bytes using specified encodings and to and from arrays of Chars. An array copy method is thrown in for good measure. EDIT :- Version 1.1 posted. See post #4 for details. Download link: www.b4x.com/android/files/ByteConverter1.1.zip Last edited by a moderator: Dec 15, 2015 Click to expand...
It's occasionally useful to be able to poke around in things as arrays of bytes so this library lets you do it. It can transform arrays of primitive types to and from arrays of bytes with the "endian-ness" of the conversion specified. If you need endian-ness you will either know about it or rather quickly find out. Byte arrays can be transformed to and from a hexadecimal string representation. Strings can be transformed to and from arrays of Bytes using specified encodings and to and from arrays of Chars. An array copy method is thrown in for good measure. EDIT :- Version 1.1 posted. See post #4 for details. Download link: www.b4x.com/android/files/ByteConverter1.1.zip
P Pauloc New Member Licensed User Longtime User Sep 4, 2012 #21 Good evening I downloaded byteconverter several times WinZip cannot unzip it , says it is corrupted ? Could you verify and inform me : mail : " [email protected] " Merci d'avance Best regards
Good evening I downloaded byteconverter several times WinZip cannot unzip it , says it is corrupted ? Could you verify and inform me : mail : " [email protected] " Merci d'avance Best regards
klaus Expert Licensed User Longtime User Sep 4, 2012 #22 I downloaded it right now and unziped it with 7Zip without any problem. Best regards.
P Pauloc New Member Licensed User Longtime User Sep 5, 2012 #23 re klaus said: I downloaded it right now and unziped it with 7Zip without any problem. Best regards. Click to expand... I can't understand I tried with winzip12 , winrar , 7zip , on 2 computers Win7 and i can't unzip it ???? I never had any problem like that , and just now i unzipped a few files to try without problem ??? Any idea or possibility to post unzipped file Thanks
re klaus said: I downloaded it right now and unziped it with 7Zip without any problem. Best regards. Click to expand... I can't understand I tried with winzip12 , winrar , 7zip , on 2 computers Win7 and i can't unzip it ???? I never had any problem like that , and just now i unzipped a few files to try without problem ??? Any idea or possibility to post unzipped file Thanks
klaus Expert Licensed User Longtime User Sep 5, 2012 #24 Have you tried to download it once again ? I had sometimes the problem and downloading again worked. If not ask Erel for the non ziped files. Best regards.
Have you tried to download it once again ? I had sometimes the problem and downloading again worked. If not ask Erel for the non ziped files. Best regards.
R Rafal Galewski Member Licensed User Longtime User Nov 24, 2012 #25 Byte Array To Decimal and Decimal to string Hi, How to use Your converter convert: Byte Array to Decimal And then Decimal to String ? Please send to me how to do it. Thnk You in Advance.
Byte Array To Decimal and Decimal to string Hi, How to use Your converter convert: Byte Array to Decimal And then Decimal to String ? Please send to me how to do it. Thnk You in Advance.
agraham Expert Licensed User Longtime User Nov 24, 2012 #26 Rafal Galewski said: Byte Array to Decimal Click to expand... Java doesn't have a Decimal type
R Rafal Galewski Member Licensed User Longtime User Dec 4, 2012 #27 Decimal Yes, I would like use data as HEX or Decimal . Co:sign0085:nvert HEX to decimal
raphael75 Active Member Licensed User Longtime User Dec 13, 2012 #28 If you want to convert hexadecimal number stored as a string to a decimal number you can use following code: Code: Copy Dim Str_HexNumber As String Str_HexNumber = "FF" Dim Int_Number As Int Int_Number = Bit.ParseInt(Str_HexNumber, 16) ' => Int_Number = 255 Last edited: Dec 14, 2012
If you want to convert hexadecimal number stored as a string to a decimal number you can use following code: Code: Copy Dim Str_HexNumber As String Str_HexNumber = "FF" Dim Int_Number As Int Int_Number = Bit.ParseInt(Str_HexNumber, 16) ' => Int_Number = 255
R Rafal Galewski Member Licensed User Longtime User Dec 14, 2012 #29 raphaelcno said: If you want to convert hexadecimal number stored as a string to a decimal number you can use following code: Code: Copy Dim Str_HexNumber As String Str_HexNumber = "FF" Dim Int_Number Int_Number = Bit.ParseInt(Str_HexNumber, 16) ' => Int_Number = 255 Click to expand... And how change decimal or Hex to string ? Thank You
raphaelcno said: If you want to convert hexadecimal number stored as a string to a decimal number you can use following code: Code: Copy Dim Str_HexNumber As String Str_HexNumber = "FF" Dim Int_Number Int_Number = Bit.ParseInt(Str_HexNumber, 16) ' => Int_Number = 255 Click to expand... And how change decimal or Hex to string ? Thank You
raphael75 Active Member Licensed User Longtime User Dec 14, 2012 #30 Rafal Galewski said: And how change decimal or Hex to string ? Click to expand... You can try this: Code: Copy Dim Int_Number As Int Int_Number = 255 Dim Str_Number As String Str_Number = Int_Number ' => Str_Number = "255" (string)
Rafal Galewski said: And how change decimal or Hex to string ? Click to expand... You can try this: Code: Copy Dim Int_Number As Int Int_Number = 255 Dim Str_Number As String Str_Number = Int_Number ' => Str_Number = "255" (string)
R Rafal Galewski Member Licensed User Longtime User Dec 22, 2012 #31 raphaelcno said: You can try this: Code: Copy Dim Int_Number As Int Int_Number = 255 Dim Str_Number As String Str_Number = Int_Number ' => Str_Number = "255" (string) Click to expand... THank YOU:sign0098:
raphaelcno said: You can try this: Code: Copy Dim Int_Number As Int Int_Number = 255 Dim Str_Number As String Str_Number = Int_Number ' => Str_Number = "255" (string) Click to expand... THank YOU:sign0098:
kiki78 Active Member Licensed User Longtime User Feb 12, 2013 #32 Partial conversion Dear agraham, First, many thank's for this usefull library. May you add, in future release, partial conversion of array ? For now we can do that with ArrayCopy before. But it's simpler if we can have, for example, "Sub2" with Offset and Count parameters. Best Regards
Partial conversion Dear agraham, First, many thank's for this usefull library. May you add, in future release, partial conversion of array ? For now we can do that with ArrayCopy before. But it's simpler if we can have, for example, "Sub2" with Offset and Count parameters. Best Regards
T TK Tang New Member Licensed User Longtime User Apr 8, 2013 #33 Hi, I am a new b4a user. I just downloaded ByteConverter library file and noticed it is in dll file format which I do not know how to have it recognised by B4A software. I noticed all other library files format is in xml and jar but this one is different. What should I do to get this library recognised in B4A? Thanks !
Hi, I am a new b4a user. I just downloaded ByteConverter library file and noticed it is in dll file format which I do not know how to have it recognised by B4A software. I noticed all other library files format is in xml and jar but this one is different. What should I do to get this library recognised in B4A? Thanks !
agraham Expert Licensed User Longtime User Apr 8, 2013 #34 Sounds like you downloaded the Basic4ppc library. The Basic4android version is in the first post of this thread.
Sounds like you downloaded the Basic4ppc library. The Basic4android version is in the first post of this thread.
T TK Tang New Member Licensed User Longtime User Apr 8, 2013 #35 Hi Andrew, Actually, I downloaded the attached file from the first post as that is the only one I can find in this forum. Appreciate if you can re-send the xml/jar format files please. Thanks..TK Tang
Hi Andrew, Actually, I downloaded the attached file from the first post as that is the only one I can find in this forum. Appreciate if you can re-send the xml/jar format files please. Thanks..TK Tang
agraham Expert Licensed User Longtime User Apr 8, 2013 #36 I've just downloaded it, as have 2790 others, and it's fine. What is the name of the file you download and what size is it? It should be ByteConverter1.1.zip with a size of 11,214 bytes.
I've just downloaded it, as have 2790 others, and it's fine. What is the name of the file you download and what size is it? It should be ByteConverter1.1.zip with a size of 11,214 bytes.
T TK Tang New Member Licensed User Longtime User Apr 9, 2013 #37 It's ok now with the zip file. No problem is compiling. Thanks..TK
kiki78 Active Member Licensed User Longtime User Sep 19, 2013 #38 Hi agraham, Another time many thanks for all of your contribution. In future release of this library, may you add conversion from and to single primitive, not only array of primitive ? Best Regards
Hi agraham, Another time many thanks for all of your contribution. In future release of this library, may you add conversion from and to single primitive, not only array of primitive ? Best Regards
K kimble01 Member Licensed User Longtime User Jan 30, 2014 #39 If this is the wrong place to ask this I apologize, but I have a string of hex bytes coming over a serial connection: "68FF30303030303235" when I use ByteConverter to parse this to bytes: conv.HexToBytes("68FF30303030303235") the resulting array at position 1 contains -1! Shouldn't that be 255? Thanks for the library, it's been truly useful.
If this is the wrong place to ask this I apologize, but I have a string of hex bytes coming over a serial connection: "68FF30303030303235" when I use ByteConverter to parse this to bytes: conv.HexToBytes("68FF30303030303235") the resulting array at position 1 contains -1! Shouldn't that be 255? Thanks for the library, it's been truly useful.
raphael75 Active Member Licensed User Longtime User Jan 30, 2014 #40 kimble01 said: when I use ByteConverter to parse this to bytes: conv.HexToBytes("68FF30303030303235") the resulting array at position 1 contains -1! Shouldn't that be 255? Click to expand... A byte is shown as a value between -128 and +127, so FF (255) is shown as -1. If you want to convert a byte to an integer value between 0 and 255, you can use this : Dim Int_Byte As Int Int_Byte = Bit.AND(0xff, Byte)
kimble01 said: when I use ByteConverter to parse this to bytes: conv.HexToBytes("68FF30303030303235") the resulting array at position 1 contains -1! Shouldn't that be 255? Click to expand... A byte is shown as a value between -128 and +127, so FF (255) is shown as -1. If you want to convert a byte to an integer value between 0 and 255, you can use this : Dim Int_Byte As Int Int_Byte = Bit.AND(0xff, Byte)