BUG-582: Operate on characters when checking for leading digit

Do not use strings when we are checking/reconstructing the leading
character -- this allows for more efficient operation.

Change-Id: I4de105ddb9af39e4a28ccc72bc79a15b410ed706
Signed-off-by: Robert Varga <rovarga@cisco.com>