RosettaCodeData/Task/Character-codes/NetRexx/character-codes.netrexx

24 lines
816 B
Plaintext

/* NetRexx */
options replace format comments java crossref symbols nobinary
runSample(arg)
return
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
method runSample(arg) private static
-- create some sample data: character, hex and unicode
samp = ' ' || 'a'.sequence('e') || '$' || '\xa2'.sequence('\xa5') || '\u20a0'.sequence('\u20b5')
-- use the C2D C2X D2C and X2C built-in functions
say "'"samp"'"
say ' | Chr C2D C2X D2C X2C'
say '---+ --- ------ ---- --- ---'
loop ci = 1 to samp.length
cc = samp.substr(ci, 1)
cd = cc.c2d -- char to decimal
cx = cc.c2x -- char to hexadecimal
dc = cd.d2c -- decimal to char
xc = cx.x2c -- hexadecimal to char
say ci.right(3)"| '"cc"'" cd.right(6) cx.right(4, 0) "'"dc"' '"xc"'"
end ci
return