static int32_t _get_base64_decoded_char()

in sdk/src/azure/core/az_base64.c [119:164]


static int32_t _get_base64_decoded_char(int32_t c, _az_base64_mode mode)
{
  if (mode == _az_base64_mode_url)
  {
    if (c == '+' || c == '/')
    {
      return -1; // can't use + or / with URL encoding
    }

    if (c == '-')
    {
      c = '+'; // - becomes a +
    }
    else if (c == '_')
    {
      c = '/'; // _ becomes a /
    }
  }

  if (c >= 'A' && c <= 'Z')
  {
    return (c - 'A');
  }

  if (c >= 'a' && c <= 'z')
  {
    return 26 + (c - 'a');
  }

  if (c >= '0' && c <= '9')
  {
    return 52 + (c - '0');
  }

  if (c == '+')
  {
    return 62;
  }

  if (c == '/')
  {
    return 63;
  }

  return -1;
}