Hex values in byte
I need to encode a message string that consists of a byte array to be sent to a device.
Two of the items are numeric values that are to be represented as hex 0x00 - 0xFF.
This needs to be placed into a single byte.
My question is this, can I use a short for my numeric value and then cast that value to byte like this
short s = 200;
byte b = (byte)s;
With this fill the byte with the hex value 0xC8
If not, how can I do this?
Thanks
burferd wrote:
My question is this, can I use a short for my numeric value and then cast that value to byte like this
short s = 200;
byte b = (byte)s;Yes and no. You'll get the byte 0xC8 into b that way, but its numerical value will be -56, not 200. Since you want an array of bytes, I assume this won't matter.
But why do you want to do it that way anyway? And why a short, not an int?
And by the way, 0xC8 is also a "numeric value".
Similar Messages
-
How to sum space delimited hex values in a string, and do other stuff?
Hello
I am trying to write a Bourne shell script that takes a non-constant-length character string as input, converts each character to hexidecimal value, sums each value, takes the two's complement of the sum, logically ANDS it with FF, and if any of the resultant "nibbles" are a-f, print/save that nibble as A-F, for later display as a two-character-long character string
For example, assume a variable (as in non-constant) length variable $A
A="w04:0;2"
the road that I started down was to define
B=$( echo $A | od -An -t x1 -N"${#A}" )
# for this example, $B=77 30 34 3a 30 3b 32
It's the middle part where I need some magic. What I want to do is add the whitespace-delimited hex values of this string, for this example
C=77+30+34+3a+30+3b+32
so for this example, $C=1b2
then take two's complement of $C; for this example, $TWOS_COMP=ffff ffff ffff ffe4e
and logically AND it with FF; for this example, almost-final answer is 4e
then save final result as uppercase character string variable (for this example, variable's contents would be 4E)
Is what I'm trying to do intuitively obvious to any of you gurus out there, that could rattle off an answer? I'm okay with trashing my approach thus far and trying something totally different, within the constraint that it run inside a Bourne shell script.
Thanx in advance, if anybody can help!I've made progress. I've converted each character of a non-constant-length string $A into a space-delimited string of hex values, added them up, and retained the least significant byte (i.e., the 8 least significant bits). Here's how:
B=$( echo $A | od -An -t x1 -N"${#A}" )
D=0
for C in $B; do
C=0x$C
D=$(($D + $C))
done
D=$(($D & 16#FF))
D=`echo "ibase=10;obase=16;$D" | bc`
The missing piece now is how to take the two's complement of $D. Anybody out there with any ideas on how to handle the two's complement piece inside a Bourne shell?
Thanx -
READBINARY and HEX values.
I have a small JPG that I've converted into a RAW RGB format.
I've tried every combination of TOBASE64(), FORMATBASEN(), and
TOSTRING() that I can think of but still can't read the values.
For instance, if I open the .RAW file in PaintShop Pro, I can
see that the first pixel at (1,1) has an RGB set of 84,82,73. If I
open the JPG and look at the same pixel, the same RGB value of
84,82,73 which is kind of brownish grey.
If I open the .RAW is a hex editor, I can see the hex values
as "84-82-73-82-88-79-8c",etc. So, I would like to use
CFFILE/READBINARY to read the first set of RGB values. In reality,
I would like to read all sets of RGB values, three at a time.
How is this done?
Gracias.Have you had a look at Christian Cantrell's method of
Using
ColdFusion to Write Out Binary Data. You could then just put
the number of bytes in place of
arrayLen(pic), remembering that one RGB set is 3 bytes. -
Problem converting hex -values changes
Guys,
I have a hex value 0x81(ascii 129). when I convert that to a string by passing this value through byte array it gets converted to " ? "(ascii 63) which is 3f in hex when converted back. I am not sure what is wrong here. Could someone help me.
Thanks in advance.Guys,
I have a hex value 0x81(ascii 129). when I convert
that to a string by passing this value through byte
array it gets converted to " ? "(ascii 63) which is
3f in hex when converted back. I am not sure what is
wrong here. Could someone help me.
Thanks in advance.this is an extended ascii char a u with two dots on it. The default encoding for Strings is iso-8859-1 and I guess this char is not supported there. When creating a String specifiy encoding utf8. -
Assigning a hex value to a variable and getting binary value of a variable.
I try to develop java programs and I need to do a conversion unicode to EBCDIC and vice versa.
How can I assign hex values to variables to build UTF-EBCDIC and EBCDIC-UTF table and get hex or binary value of data to compare it to value of in the table?
I did a conversion like this with PL/1 before. I do not know how can I do it with Java. Because I am new to Java.
Thank you in advance.I will run java code in mainframe and java uses
unicode for data in default and mainframe environment
is EBCDIC. So I have to translate the data from
unicode to ebcdic.I said I think String supports EBCDIC encoding...
String ebcdic = new String(ebcdicBytes, "Cp500");
http://java.sun.com/j2se/1.4.2/docs/guide/intl/encoding.doc.html -
How to print the HEX values of non-displayable characters!
I am trying to tokenize a string that contains non-displayable characters i.e. EBCDIC or ASCII. How can I print the HEX values of the non-displayable characters. e.g.
"StartTEST1TEST2TEST3TEST4TEST5TEST6TEST7TEST812END"
How can print the HEX values of in the above string. Any help is appreciated.
Thankschar ch = 28; // or whatever character you want to look at.
String hexString = Integer.toHexString(ch);
System.out.println(hexString); -
I read in a text document from a server different HEX values depending on the equipment i used. The Hex value is sent to a VI for TMT commands.
And the entrance which must be presented as HEX display.
I want to "convert" an appended path string with HEX value for example (0000 3D11 03) to HEX display (0000 3D11 03)Duplicate Post
Gaurav k
CLD Certified !!!!!
Do not forget to Mark solution and to give Kudo if problem is solved. -
Possible to supply a hex value to solid's color property?
I know the AE Scripting Guide specifies that we have to supply an array of RGB values if we wish to change a solid's color property. I'm just curious if it is possible to supply a hex value in lieu of an RGB array. Does anybody have any experience with a work around?
Thanks!Dan,
Just wanted to add that I didn't realize your function assumed the hex color value would be passed in as `0xFFFFFF`. My data was passed in as a string such as `FFFFFF`. To fix, I just added one line:
function hexToColor(theHex){
theHex = parseInt(theHex,16);
var r = theHex >> 16;
var g = (theHex & 0x00ff00) >> 8;
var b = theHex & 0xff;
return [r/255,g/255,b/255];
Thought this might help somebody who had the same data coming in question. Thanks, again for the help. -
How to Pass a HEX-Value to AdobeLifeCycle (TA:SFP) .
Hello all,
how to pass a HEX-Value to print a BLACK RIGHT-POINTING TRIANGLE?
I want to pass a HEX value to AdobeLifeCycle (TA:SFP).
This is done as follwoing:
*-- Variablen
DATA hex(2) TYPE x.
SET BIT: 01 OF hex TO 0,
02 OF hex TO 0,
03 OF hex TO 1,
04 OF hex TO 0,
05 OF hex TO 0,
06 OF hex TO 1,
07 OF hex TO 0,
08 OF hex TO 1,
09 OF hex TO 1,
10 OF hex TO 0,
11 OF hex TO 1,
12 OF hex TO 1,
13 OF hex TO 1,
14 OF hex TO 0,
15 OF hex TO 1,
16 OF hex TO 0.
The HEX-VALUE ist u201E25BAu201C from the codepage 4110 = BLACK RIGHT-POINTING TRIANGLE, (use TA:SPC to see it).
I set the HEX-VALUE before i call the PDF-OUTPUT:
move hex to ls_frmglobal-hex. u201E(the field ist defined as u201ERAWSTRINGu201C)
Then i call the Output;
Now call the generated function module
CALL FUNCTION fm_name
EXPORTING
/1bcdwb/docparams = fp_docparams
frmglobal = ls_frmglobal
frmisu = ls_frmisu
frminf = ls_frminf
connections = connections
t_sums = t_sums
EXCEPTIONS
usage_error = 1
system_error = 2
internal_error = 3
OTHERS = 4.
The result is u201E25BAu2018 instead of the BLACK RIGHT-POINTING TRIANGLE.
Can any one have a idea what is goning wrong?
I know how to print a Triangle on the Designer the quetion is how to pass the Hex-Value from a different codepage than the Stanndard codepage which we use.
Thanks and regards
IbrahimI am trying to match \xfa which means that match faas
a hex value.
All I want to know is how to use the RE class tocheck
for a cetain hex value.
Correction:
If the data is numeric, it can be matched using a hex,
or octal representation for the regular
expression. for instance, the numeric value 6 will be
matched with either of the following regexes (hex,
and octal, respectively). Read the API for
the Pattern class if this doesn't make sense.
"\06"
"\006"(Should have checked first...) -
Hi,
How can I convert HEX value to CHAR value.
The Code in <b>non Unicode</b> system is:
DATA: t_text LIKE tline OCCURS 0 WITH HEADER LINE.
constants: c_hex_20a5(2) TYPE x VALUE '20A5'.
t_text-tdline = 'seller of the item so listed. A legend of the Seller Code(s) is as'.
TRANSLATE t_text-tdline USING c_hex_20a5.
The same code give error in <b>Uni-Code</b> system:
<b>error is "c_hex_20a5 must be an character type object (C, N, D, T or String type)."</b>
If anyone know, what is the solution, please let me know.
Thanks!
Puneet.Hi,
Try declaring the Hex chars using the ABAP char utilities. This is just a sample piece of code on how to declare and use:
CLASS cl_abap_char_utilities DEFINITION LOAD.
DATA: ws_lf TYPE c VALUE cl_abap_char_utilities=>cr_lf.
data: c_newline TYPE x VALUE '0D'. [ it is zero D, for carriage return ]
ws_lf = c_newline.
CONCATENATE it_tab-maktx
ws_lf
ws_template
INTO it_notificatn-template.
Hope this helps...
Regards
Subramanian -
SDIXML_DOM_TO_XML is giving hexa values not xml
Hi all,
As per the suggestion from Satish, I am using these FM to convert data> dom> xml.
but the function SDIXML_DOM_TO_XML is giving hexa values
Please advise.
CALL FUNCTION 'SDIXML_DATA_TO_DOM'
EXPORTING
NAME = 'ACCESOS'
DATAOBJECT = ACCESOS[]
IMPORTING
DATA_AS_DOM = L_DOM
CHANGING
DOCUMENT = M_DOCUMENT
EXCEPTIONS
ILLEGAL_NAME = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
SY-SUBRC.
ENDIF.
CHECK NOT L_DOM IS INITIAL.
W_RC = M_DOCUMENT->APPEND_CHILD( NEW_CHILD = L_DOM ).
IF W_RC IS INITIAL.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
W_RC.
ENDIF.
--CALL FUNCTION FOR: put the XML data ino ITAB--
CALL FUNCTION 'SDIXML_DOM_TO_XML'
EXPORTING
DOCUMENT = M_DOCUMENT
IMPORTING
XML_AS_STRING = W_STRING
SIZE = W_SIZE
TABLES
XML_AS_TABLE = IT_XML
EXCEPTIONS
NO_DOCUMENT = 1
OTHERS = 2.
IF SY-SUBRC = 0.
WRITE 'Ok'.
ELSE.
WRITE: 'Err =',
SY-SUBRC.
ENDIF.
LOOP AT IT_XML INTO XML_TAB-D.
APPEND XML_TAB.
ENDLOOP.also,
I am trying to write the XML file to file in app.server. -
Converting a hex String to its corresponding hex value...?
Yeah, I'm having quite a bit of fun guessing this one... :p
I have a string of n characters and have used Integer.toHexString( ( int )str.charAt( i ) ) to convert each character to a string representing its hex value. Now I need to USE that value for bit-wise operations, like, say, applying the AND, OR, etc. operators...
Example:
hexvalue &= 0xC000FFFF; //the second value is the one extracted from the string;
How can achieve this...? Any help is greatly appreciated... :}Since a Java char is numerically a Java short, you can apply bitwise operators to chars directly - the conversion to hex simply changes the way that the char is viewed; the result can also be viewed as a number in other bases.
For instance, the char 'A' can be also be represented as any of the following values:
binary - 1000001
octal - 101
decimal - 65
hex - 41
Likewise, 'Z' can also be viewed as
binary - 1011010
octal - 132
decimal - 90
hex - 5A
"Anding" the letter 'A' with 'Z' ('A' & 'Z') or doing the same using any of the other representations will result in (binary 1000000, octal 100, decimal 64, or hex 40) - the bit pattern is the same, only the representation of the result varies. -
Adobe Illustrator CC 2014 not allowing me to change colors by typing in a precise hex value.
Over the last two days, I have lost the ability to type in a hex value to the color picker to change an object's color. Anyone else experience this and know of fixes? I can select from the pre-made swatches or gradient-color picker field, but I need to be able to enter precise hex values per my style guide.
JWoo,
What happens if you use the Web Safe RGB from the Color palette flyout and insert the values there?
For failures in general, you may try the list.
The following is a general list of things you may try when the issue is not in a specific file (you may have tried/done some of them already); 1) and 2) are the easy ones for temporary strangenesses, and 3) and 4) are specifically aimed at possibly corrupt preferences); 5) is a list in itself, and 6) is the last resort.
If possible/applicable, you should save curent artwork first, of course.
1) Close down Illy and open again;
2) Restart the computer (you may do that up to at least 5 times);
3) Close down Illy and press Ctrl+Alt+Shift/Cmd+Option+Shift during startup (easy but irreversible);
4) Move the folder (follow the link with that name) with Illy closed (more tedious but also more thorough and reversible);
5) Look through and try out the relevant among the Other options (follow the link with that name, Item 7) is a list of usual suspects among other applications that may disturb and confuse Illy, Item 15) applies to CC, CS6, and maybe CS5);
Even more seriously, you may:
6) Uninstall, run the Cleaner Tool (if you have CS3/CS4/CS5/CS6/CC), and reinstall.
http://www.adobe.com/support/contact/cscleanertool.html -
How to add HEX values in a Report.
I have a special requirement. I need to add hex values in a report. To be specific, the special HEX characters: 0D 0A 0C 0C, has to be added to TOP of PAGE event.
Drawing What I want will be something like that:
CR/LF FF/FFABCDEFHGIJKLMNOZVCXC
This is a Report that has to be send to the spool. Once in the spool will be converted to TXT file. I created a small code using print control function but still It is doesnt working.
I defined a print control ZPAGE as 0D 0A 0C 0C.
Any idea how to do this?.
** This report doesnt include the Top-of Page event.
** Example Report.
REPORT ZCAPRTHEX2 NO STANDARD PAGE HEADING.
Data: String1(120) type c value 'ABCDEFHGIJKLMNOZVCXC'.
WRITE : /.
PRINT-CONTROL FUNCTION 'ZPAGE'.
WRITE : string1.
This is what I see in SP01 as HEX View
ABCDEFHGIJKLMNO ZVCXC #ZPAGEIf you download spool to file like that, you are still getting the spool in SAP format, it's not going to have the hex chars. You need to print the file by clicking on printer button. SAP generates file in printer readable format and send it to printer. I'm refering to that file.
Ask your basis folks to write the spool output reqest file to a file instead of sending to the printer. Open that file in hex viewer.
Regards
Sridhar -
How do I read a hex value and then convert to the binary equivalent?
I am reading hex values from a register on my unit under test. I only want to monitor certain bits in the hex value to check a status. I have everything down to run the program except how to read my hex values in binary form. Any suggestions out there?
If this is just a matter of display, then right click and choose "Format & Precision...". Beware, this works only with integer indicators (I8/16/32 and U8/16/32).
If the problem is to extract a bit value in a specific position, then go to the "Advanced >> Data manipulation" sub-palette where are all bit manipulation functions (rotate, shift, split...).
Don't forget either the logical functions (And, Or...) in the boolean sub-palette, where is also the "number to boolean array" function (to be used in conjunction with an index array node).
Another option is to use string conversion functions, in the "String >> String/Number conversion" sub palette.
Have a look to the attached image.
Enough ?
Chilly Charly (aka CC)
E-List Master - Kudos glutton - Press the yellow button on the left...
Attachments:
Hex_&Bin.tif 20 KB
Maybe you are looking for
-
What are the advantages of using Map IDs?
Hi: I am trying to find out the advantages for using map ids as opposed to just using the file names for the topics, but I couldn't find this information in the RH7 Help or the forums. Can you please list the advantages and disadvantages. Also, I am
-
Is there a fast way to convert mp3 to mp4?
Got a large library of audiobooks in itunes that are in mp3 format. I want to convert them to mp4. Join Together by Doug Adams does a great job of this but is sloooow (appears that Quicktime is running in single step mode.) Is there a faster way t
-
How to change "Day ends at" to after midnight, in iCal OS X Lion?
Hello Apple/Mac community. Any help on this questions would be greatly appreciated!!!!! Donnie C
-
HT4796 iPhoto did not pick up the photos I migrated. What can I do?
my migrated photos were not picked up by iPhoto, and I can't find them. How do I get them?
-
Deploying Oracle Reports in Oracle Application Server
i have installed Oracle Developer Suit for oracle Report Builder and also installed Oracle 9i AS successfully. I am creating a report in report builder in JSP format. I want to deploy it to oracle application server, can anybody help me in doing this