|
I got a file from our parcel service with routing information and the ascii decimal value (!) for that id character. So the file looks like this: #Fields: DestinationCountry|BeginPostCode|EndPostCode|ServiceCodes|RoutingPlaces|SendingDate|O-Sort|D-Depot|GroupingPriority|D-Sort|BarcodeID| ES|46101|46109|S299,S302303|GEFDX,GEBED,GENLD,GEALC,GEITD,GEFCO|*|*|0746|9|*|37|
Unfortunately "ASCII" isn't very specific. There are lots of different codepages that are all referred to as ASCII! For the most common characters, ASCII and Unicode have the same values as well.
If simply using the unicode characters is good enough for you, then you can use RPG's built-in support for UCS2. That makes the code very simple. Here's a quick-and-dirty program that you can try:
H DFTACTGRP(*NO) D ds D unicode 1C D decimal 5U 0 overlay(unicode) D mychar s 1A /free decimal = 37; mychar = %char(unicode); dsply mychar; *inlr = *on; /end-free (the %char() BIF converts the unicode text into ordinary EBCDIC)If Unicode isn't good enough, then you need to know the exact code page of ASCII, since ASCII can be interpreted many different ways it becomes important to know precisely what you're referring to.
In any case, you can always convert from the decimal numeric value (37 in your example) to a character field by doing this:
D ds D ascii 1A D decimal 3U 0 overlay(ascii) decimal = 37;Then you'd have the ASCII character in the "ascii" field, and you'd use iconv() to convert from a particular ASCII codepage to a particular EBCDIC one. That would give you the most precise translation.
But, if they don't specify an exact ASCII codepage, the Unicode method is probably good enough, since they're probably using invariant characters in that case.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.