Wednesday, August 10, 2022

Crystal Reports Custom Report Function: Superscript Text generator.

 A simple custom report function for Crystal Reports that will take a numeric value and generate a string of UTF8 superscripts of the digits.


//font must be Arial Unicode MS or other font with Unicode support
//1 2 3 4 5 6 7 8 9 0
//Hex
// 2071 00B2 00B3 2074 2075 2076 2077 2078 2079 2070
//Dec
// 0185 0178 0179 8308 8309 8310 8311 8312 8313 8304
Function (numberVar SuperScriptNumber)
//If 1 thru 9 and then zero since we're not a zero based array
Local NumberVar Array subs := [0185,0178,0179,8308,8309,8310,8311,8312,8313,8304];
Local NumberVar x;
Local NumberVar DecValue;
Local StringVar NumString := ToText(SuperScriptNumber,0,"","");
Local StringVar SuperString := "";
For x:= 1 to Len(NumString) Do
(
	DecValue:= ToNumber(Mid(NumString,x,1));
	if DecValue = 0 then SuperString := SuperString + chrw(subs[10])
	else
	SuperString := SuperString + chrw(subs[decValue]);
);
SuperString