1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-10-22 06:22:58 +02:00

Adds lib-string-utils

This commit is contained in:
Dmitry Vedenko
2021-05-25 16:07:10 +03:00
parent 733cf89cff
commit 52a835bd61
11 changed files with 356 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
#pragma once
/*!********************************************************************
Audacity: A Digital Audio Editor
@file HexHelpers.h
@brief Define helper functions for hex-to-num conversion.
Dmitry Vedenko
**********************************************************************/
#include <cstdint>
#include <cassert>
#include <cctype>
namespace audacity
{
inline uint8_t HexCharToNum (char c) noexcept
{
assert (std::isxdigit (c) != 0);
if ('0' <= c && c <= '9')
return c - '0';
else if ('A' <= c && c <= 'F')
return c - 'A' + 10;
else if ('a' <= c && c <= 'f')
return c - 'a' + 10;
return 0;
}
}