cancel
Showing results for 
Search instead for 
Did you mean: 

Is there a way in Crystal Reports to convert Binary Characters to Text

Former Member
0 Kudos

I have a block of text that has binary characters throughout.  I need to be able to convert them to ascii text.

Accepted Solutions (0)

Answers (1)

Answers (1)

JWiseman
Active Contributor
0 Kudos

hi Marjorie,

there's no built in way to do this but that's okay. i've attached a character conversion report that has a Custom Function that you can add to your businessobjects or crystal server repository...or just copy the code from report to report if you don't have those.

once you download the attachment, extract the contents and then change the .txt extension to .rpt.

please note that i just built this this morning...i've been meaning to do this for a while but your forum post got me to do it. let me know if you see any issues.

the way that it works is that the custom function takes in 3 text values..one for the type of field that you want to convert (e.g. "binary"), one for the type that want to display (e.g. "char") and then the value (i.e. your field). note that when the field is a number, you need to ensure that you convert it to text without commas and decimals...i.e. totext({yourfield, 0, '')...you'll see in the sample though in the "test" formula on the report.

there's a bunch of different options in the custom function so not just binary to char. see the two prompts / parameters to change up the input type and output type.

the only problem i am worried about is how the binary looks like in your database...is it one long delimited string for example. the custom function takes in a single value...so let me know the format of your data if it's not a single value.

i hope this helps,

jamie

Former Member
0 Kudos

What I am dealing with is a field that contains any where from 1 to 256 characters.  Some of which are binary and some of which are ascii. I would like to read the entire field and translate the binary characters to ascii text.

JWiseman
Active Contributor
0 Kudos

can you post a couple of examples?

this may be quite difficult to do as your db record may have a 0 or 1 or 10 (etc.) in it which may be a number that should not be converted.

hopefully your field will be delimited though for the binary values that you do want to be converted.

JWiseman
Active Contributor
0 Kudos

hi Marjorie,

can you please have a look at the attached report...extract the contents and change the .txt extension to .rpt.

there is a new Report Custom Function in the Report > Formula Workshop you can add to your repository. if you don't have businessobjects or crystal reports server then create a new Custom Function on your existing report and copy and paste the syntax over.

this new function will convert either regular strings to binary or binary strings to characters. in other words you can use it against your database field and it will loop through the records like you wanted.

syntax would be BinaryCharConversion ({?Input},{?InputType}) or BinaryCharConversion (your binary field},'binary') where the 2nd parameter represents what type the source is...either binary or char.

the converter does work for a couple of control chars like chr(10), chr(9), and chr(13) but all others for now are converted to ''

please try this against your data and see if everything's okay.

cheers,

jamie