Question
· Nov 19, 2022

Cache data types conversion

Hi Guys,

I've this :

- NodeJS example,

let buf = Buffer.from('02010605166E2A0923100950205450524F424520303030323730', 'hex')

let temper = buf.readInt16BE(7) / 100

 

- Python example,

import binascii

buf = binascii.a2b_hex('02010605166E2A0923100950205450524F424520303030323730')

temper = int.from_bytes(x[7:9],byteorder='big') / 100

 

what would be the equivalent of this using Cache scripts?

 

Thanks Guys 

Product version: Caché 2014.1
Discussion (4)3
Log in or sign up to continue

Hi @Rochdi Badis 


With COS I don't know if is possible to do what you need. If you are using Ensemble, you can try to to achieve your needs using JavaGateway.

Some useful links:

https://www.baeldung.com/java-byte-arrays-hex-strings

https://stackoverflow.com/questions/7619058/convert-a-byte-array-to-integer-in-java-and-vice-versa

Let we know how you resolved this.

Regards.