* Generates a Html encoded hex color string (#aabbcc) with null termination. * * @param buf the buffer to write the string to * @param bufSize the maximum buffer size (must be at least 8 characters) * @return The amount of chars written to buf including the null terminator. */
| 44 | * @return The amount of chars written to buf including the null terminator. |
| 45 | */ |
| 46 | size_t HtmlColor::ToNumericalString(char* buf, size_t bufSize) const |
| 47 | { |
| 48 | if (bufSize >= 8) |
| 49 | { |
| 50 | buf[0] = '#'; |
| 51 | |
| 52 | uint32_t color = Color; |
| 53 | for (size_t indexDigit = 6; indexDigit > 0; --indexDigit) // note pre-decrement |
| 54 | { |
| 55 | buf[indexDigit] = hexdigit(color & 0x0000000f); |
| 56 | color >>= 4; |
| 57 | } |
| 58 | buf[7] = '\0'; |
| 59 | |
| 60 | return 8; |
| 61 | } |
| 62 | return 0; |
| 63 | } |
nothing calls this directly
no test coverage detected