Skip to main content
Announcements
Document boards are being consolidated, this board no longer allows NEW documents READ MORE

Replace characters with Ascii numbers in a string

cancel
Showing results for 
Search instead for 
Did you mean: 
jagan
Luminary Alumni
Luminary Alumni

Replace characters with Ascii numbers in a string

Last Update:

Aug 26, 2014 5:06:55 AM

Updated By:

jagan

Created date:

Aug 26, 2014 5:06:55 AM

Hi,

The below code helps in replacing characters with ASCII codes in a string in Load script

For example

ABC is converted to 656667- since ASCII code of A is 65, B is 66 and C is 67.

CharMap:

Mapping LOAD

Chr(RecNo() - 1) AS Char,

RecNo() - 1 AS Asciicode

AutoGenerate 256;

Data:

LOAD

Text,

MapSubString('CharMap', Text) as formattedText

FROM DataSource;

Hope this helps.

Regards,

Jagan.

Comments
richho_microp
Contributor III
Contributor III

You life saver, works perfectly.

Thank you

0 Likes
prasadcm
Creator II
Creator II

Hey,

Thanks.Worked perfectly for a certain issue.

0 Likes
colinodonnel
Creator II
Creator II

Thanks,

Have tweaked this slightly as I need the Ascii for one character only.

Once the Ascii code is identified, it is then easy to replace 

//Code to find the ascii code of a single char

CharMap:
Mapping
LOAD
Chr(RecNo() - 1) AS Char,
RecNo() - 1 AS Asciicode
AutoGenerate 256;

Data:
LOAD
Text,
MapSubString('CharMap', Text) as formattedText
;
LOAD
mid(Text,9,1) as Text
Resident Table;

 

// code then added to script to replace 

Replace(text, chr(10), ' ') as text

 

0 Likes
Version history
Last update:
‎2014-08-26 05:06 AM
Updated by: