I am looking to write the Oracle function rawtohex in C#.
I am looking at existing code that has been written and would like to be confirm if it is accurate.
public static string AsHexString1(this char[] chars)
{
StringBuilder sb = new StringBuilder();
foreach (var ch in chars)
{
int lowNibble = (int)ch % 16;
int highNibble = (int)ch / 16;
sb.Append(highNibble <= 9 ? highNibble.ToString() : ((char)('A' + (highNibble - 10))).ToString());
sb.Append(lowNibble <= 9 ? lowNibble.ToString() : ((char)('A' + (lowNibble - 10))).ToString());
}
return sb.ToString();
}
Thanks.
As far as I know, RawToHex should be something similar to this:
I’m not sure why you’re using a char array as input, since it’s RAW data…