how can I convert text to binary data but in client action in mobile ?

how can I convert text to binary data but in client action in mobile ?

  

hi,


any idea how can I convert text to binary data but in client action in mobile ?


thanks.

what kind of text?

what kind of binary data?


For text containing base64 image, you can just remove the "data:image/png;base64," part to convert it to Image Binary Data.


Here's sample of Javascript code you can use in client action (mobile):

$parameter.fixedImage type is BinaryData.


I think in Javascript, you can assign any text to any binary data if you need to.

Harlin Setiadarma wrote:

what kind of text?

what kind of binary data?


For text containing base64 image, you can just remove the "data:image/png;base64," part to convert it to Image Binary Data.


Here's sample of Javascript code you can use in client action (mobile):

$parameter.fixedImage type is BinaryData.


I think in Javascript, you can assign any text to any binary data if you need to.

thanks! exactly what I need


Hi Daniel,

Be careful with that... what Harlin suggests isn't "real" BinaryData, it's still a text representation of binary data (in base64, each character represents 6bits of the actual binary data encoded). If obtaining the data portion of a Data URL is enough for your needs then great, Harlin's answer is perfect.

But if you really want the binary data itself like you initially mentioned, in binary format, you will need to decode the base64 representation (you can find several posts discussing this topic here, here and here) along with the description of base64 with some example data and how it is encoded/decoded. I'm sure there are Javascript libraries already in place to implement this, or you can use any modern browser's own functionality to do it for you, as you can see here.

Hope this helps.

Jorge Martins wrote:

Hi Daniel,

Be careful with that... what Harlin suggests isn't "real" BinaryData, it's still a text representation of binary data (in base64, each character represents 6bits of the actual binary data encoded). If obtaining the data portion of a Data URL is enough for your needs then great, Harlin's answer is perfect.

But if you really want the binary data itself like you initially mentioned, in binary format, you will need to decode the base64 representation (you can find several posts discussing this topic here, here and here) along with the description of base64 with some example data and how it is encoded/decoded. I'm sure there are Javascript libraries already in place to implement this, or you can use any modern browser's own functionality to do it for you, as you can see here.

Hope this helps.

Hi Jorge,


Thanks for the explanation.

I need to use the binary as image. as in here... is this going to be a correct format?


Best way to know for sure is to try it! ;-)

But no, that requires actual binary data, as far as I know.

On the other hand, if you have a URL like Harlin mentioned (starting with "data:<image-MIME-type>;base64," followed by the base64-encoded image) you can just set up your Image widget's Type to External URL and use the URL you have directly.