Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements

Breathe easy -- you now have more time to plan your next steps with Qlik!
QlikView 11.2 Extended Support is now valid through December 31, 2020. Click here for more information.

Not applicable

ASCII to text conversion

I have an SQL  database field, having value in ASCII format, how to show that text in readable format in qvw??

Sample value:

0C01000000A0DEB76FCDE7D54EB64EBC85E527D561000000000000000001000000

1 Solution

Accepted Solutions
whiteline
Honored Contributor II

Re: ASCII to text conversion

I know I said.

I don't now the format of your string.

According to ASCII table your text is something like ' Ю·oНзХN¶Nј…е'Хa'.

The script returns an empty string because there are zeros wich means 'end of string'.

5 Replies
whiteline
Honored Contributor II

Re: ASCII to text conversion

You can write a maco function that converts ASCII string into text string.

Then you can simply use it in the load script.

Not applicable

Re: ASCII to text conversion

Can you help me in writing macro?

whiteline
Honored Contributor II

Re: ASCII to text conversion

I don't now the format of your string.

I writed a sample for a simple byte ASCII encoding (for example 596F752063616E20646F206974).

Macro:

function ASCIIToText (str)

      Dim result, x

      ASCIIToText = ""

      If Len(str)<2 Then Exit Function

      If Len(str)=2 Then

           ASCIIToText = Chr(CByte("&h" & str))

           Exit Function

      End If

      result = ""

      For x=1 To Len(str) Step 2

           result = result & ASCIIToText(Mid(str, x, 2))

      Next

      ASCIIToText = result

End function

Now in the load script you can use ASCIIToText as any other function:

LOAD

      ASCIIToText(ASCIIValue) as TextValue

Resident SomeTableWithASCIIData;

Not applicable

Re: ASCII to text conversion

This macro is giving me null.. do you have any idea why??

Can you test your macro with the sample data i provided above please

whiteline
Honored Contributor II

Re: ASCII to text conversion

I know I said.

I don't now the format of your string.

According to ASCII table your text is something like ' Ю·oНзХN¶Nј…е'Хa'.

The script returns an empty string because there are zeros wich means 'end of string'.