I want to convert a given ASCII value to the corresponding character in a FOP template using velocity.
For Eg: I want ASCII value of 65 to get converted to A
I have tried putting a Character Object in the velocity context and then used Character.toChars(int) but velocity printed its address instead of the the corresponding character, can somebody tell me what I am doing wrong. Or is there a better way to do it.
In velocity context:
VelocityContext.put("char", new Character());
In FOP Template
set($asciiValue = 65)
$char.toChars($asciiValue)
You can pass your custom converter to Velocity context (as you pass Character object). But also you can change your code to this:
#set ($string = " ")
#set ($asciiValue = 65)
#set ($chars = $char.toChars($asciiValue))
#set ($letter = $string.copyValueOf($chars))
$letter
copyValueOf
is used for create String from char array.