cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
See how to use to use Text Explorer to glean valuable information from text data at April 25 webinar.
Choose Language Hide Translation Bar
View Original Published Thread

how to convert binary data into ascii codes

robust1972
Level IV


I have some analog data I need to convert it to binary basing on its value(done). Then I managed to put 8 bits together to make a binary data by jmp script. Where I need help is how to convert the binary data into text/number using ascii codes. I tried use blob to char but it reporting wrong data type....

I attached jmp table.

1 ACCEPTED SOLUTION

Accepted Solutions
ms
Super User (Alumni) ms
Super User (Alumni)


Re: how to convert binary data into ascii codes

The binary numbers in your table do not always correspond to A-Z or 0-9. These show up: " # & 0 1 2 3 4 5 6 7 ? @ A B C D E F G H I J K L M N P Q R S T U V W X _ o { } ~

And in the many cases of non-printable ascii "characters" there will be empty cells in JMP.

I've probably misunderstood your goal, but try this formula, which will make an exception for all wl among {12, 13, 26, 27, 40, 41}.

If( Contains( {12, 13, 26, 27, 40, 41}, :wl ),

  Char(

  (Matrix(

  {:Name( "0" ), :Name( "1" ), :Name( "2" ), :Name( "3" ), :Name( "4" ),

  :Name( "5" ), :Name( "6" )}

  )` * 2 ^ Index( 0, 6 )`)[1]

  ),

  Hex To Char(

  Right(

  Hex(

  (Matrix(

  {:Name( "0" ), :Name( "1" ), :Name( "2" ), :Name( "3" ),

  :Name( "4" ), :Name( "5" ), :Name( "6" )}

  )` * 2 ^ Index( 0, 6 )`)[1],

  "integer"

  ),

  2

  ),

  "us-ascii"

  )

)

View solution in original post

4 REPLIES 4
ms
Super User (Alumni) ms
Super User (Alumni)


Re: how to convert binary data into ascii codes

There is probably a simpler way, but try to paste the code below into a column formula field in the posted data table. It should give the ascii character (the first argument of Hex() alone calculates the ascii decimal code)

Hex To Char(

  Right(

  Hex(

  (Matrix(

  {:Name( "0" ), :Name( "1" ), :Name( "2" ), :Name( "3" ), :Name( "4" ), :Name( "5" ), :Name( "6" )} )` * 2 ^ [0, 1, 2, 3, 4, 5, 6])[1],

  "integer"

  ),

  2

  ),

  "us-ascii"

)

robust1972
Level IV


Re: how to convert binary data into ascii codes

Thanks MS!

I know nothing about matrix usage in jmp. for the data I posted, my ultimate goal are A: convert "wl" 0~11, 14~25 and 28~39 to text composing A-Z and 0-9. B: Other "wl"s represent a 2 digit decimal number.

your script work for A but not for B.

ms
Super User (Alumni) ms
Super User (Alumni)


Re: how to convert binary data into ascii codes

The binary numbers in your table do not always correspond to A-Z or 0-9. These show up: " # & 0 1 2 3 4 5 6 7 ? @ A B C D E F G H I J K L M N P Q R S T U V W X _ o { } ~

And in the many cases of non-printable ascii "characters" there will be empty cells in JMP.

I've probably misunderstood your goal, but try this formula, which will make an exception for all wl among {12, 13, 26, 27, 40, 41}.

If( Contains( {12, 13, 26, 27, 40, 41}, :wl ),

  Char(

  (Matrix(

  {:Name( "0" ), :Name( "1" ), :Name( "2" ), :Name( "3" ), :Name( "4" ),

  :Name( "5" ), :Name( "6" )}

  )` * 2 ^ Index( 0, 6 )`)[1]

  ),

  Hex To Char(

  Right(

  Hex(

  (Matrix(

  {:Name( "0" ), :Name( "1" ), :Name( "2" ), :Name( "3" ),

  :Name( "4" ), :Name( "5" ), :Name( "6" )}

  )` * 2 ^ Index( 0, 6 )`)[1],

  "integer"

  ),

  2

  ),

  "us-ascii"

  )

)

robust1972
Level IV


Re: how to convert binary data into ascii codes

thanks MS.

Sorry, in fact that I realized later that  "wl" 0~11, 14~25 and 28~39 are 2 digits decimal number, which only need be convert to decimal.