X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=flower%2Fstring-convert.cc;fp=flower%2Fstring-convert.cc;h=c372520c16f3acb26d53b8f2bbd983ca1f943379;hb=e90f0536f9be39ada0bef0aeb0d275dec3b2fb5b;hp=ef64af25b606fe753ac6d4015cba154f73f899fe;hpb=a8c9e8a7ca320ab0df5fd32e717fd62cd7635ce6;p=lilypond.git diff --git a/flower/string-convert.cc b/flower/string-convert.cc index ef64af25b6..c372520c16 100644 --- a/flower/string-convert.cc +++ b/flower/string-convert.cc @@ -33,6 +33,15 @@ String_convert::bool_string (bool b) return string (b ? "true" : "false"); } +string +String_convert::bin2hex (Byte bin_char) +{ + string str; + str += to_string ((char) nibble2hex_byte ((Byte)(bin_char >> 4))); + str += to_string ((char) nibble2hex_byte (bin_char++)); + return str; +} + string String_convert::bin2hex (string bin_string) { @@ -40,7 +49,7 @@ String_convert::bin2hex (string bin_string) Byte const *byte = (Byte const*)bin_string.data (); for (ssize i = 0; i < bin_string.length (); i++) { - str += to_string ((char)nibble2hex_byte (*byte >> 4)); + str += to_string ((char)nibble2hex_byte ((Byte)(*byte >> 4))); str += to_string ((char)nibble2hex_byte (*byte++)); } return str; @@ -197,9 +206,9 @@ Byte String_convert::nibble2hex_byte (Byte byte) { if ((byte & 0x0f) <= 9) - return (byte & 0x0f) + '0'; + return (Byte)((byte & 0x0f) + '0'); else - return (byte & 0x0f) - 10 + 'a'; + return (Byte)((byte & 0x0f) - 10 + 'a'); } /** Convert an integer to a string