You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a fun post to write about, right? Everyone in the IBM i world loves to deal with EBCDIC problems. Of course, when porting RPGLE to another platform you have to handle edge cases of when hexadecimal can be used.
That static hexadecimal string is Hello world$ in EBCDIC. Now, we must not forget that there are multiple versions of EBCDIC. If we were running this under a job of CCSID (or codepage) 37, then the value is Hello world$. If we were running this under CCSID 285, it would be ``Hello world£`.
Luckily, for NetRPG, .NET Core has some support for these encodings (and others too!). The parser is keeping an eye out for these hexadecimal literals.
case "x":token=newRPGToken(RPGLex.Type.STRING_LITERAL,EBCDIC.ConvertHex(EBCDIC.GetEncoding(int.Parse(Configurations["CCSID"])),tokens[i+1].Value));
Using System.Encoding we can convert a string of bytes from EBCDIC to a regular C# string. and we created a ConvertHex function to make this easier long term. We also have a function to convert an IBM i CCSID to the equivalent .NET Core encoding name. You can see those here.
Meaning, when the hexadecimal literal is found in the RPG code, the tokens are replaced with the converted string. Because .NET Core supports multiple different CCSIDs, it means we can support them too!
The text was updated successfully, but these errors were encountered:
This is a fun post to write about, right? Everyone in the IBM i world loves to deal with EBCDIC problems. Of course, when porting RPGLE to another platform you have to handle edge cases of when hexadecimal can be used.
Firstly, you can read about hexadecimal literals here in the RPGLE manual.
Let's use this RPG example:
That static hexadecimal string is
Hello world$
in EBCDIC. Now, we must not forget that there are multiple versions of EBCDIC. If we were running this under a job of CCSID (or codepage) 37, then the value isHello world$
. If we were running this under CCSID 285, it would be ``Hello world£`.Luckily, for NetRPG, .NET Core has some support for these encodings (and others too!). The parser is keeping an eye out for these hexadecimal literals.
Using
System.Encoding
we can convert a string of bytes from EBCDIC to a regular C# string. and we created aConvertHex
function to make this easier long term. We also have a function to convert an IBM i CCSID to the equivalent .NET Core encoding name. You can see those here.Meaning, when the hexadecimal literal is found in the RPG code, the tokens are replaced with the converted string. Because .NET Core supports multiple different CCSIDs, it means we can support them too!
The text was updated successfully, but these errors were encountered: