View Single Post
  #4  
Old 03-13-2020, 02:37
runio runio is offline
Friend
 
Join Date: Jul 2016
Location: Earth
Posts: 18
Rept. Given: 0
Rept. Rcvd 0 Times in 0 Posts
Thanks Given: 6
Thanks Rcvd at 16 Times in 10 Posts
runio Reputation: 0
https://en.wikipedia.org/wiki/Base36

Base34 is (0-9), (A-X)

Example code converted from Base36
Code:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

static char *base34enc(long unsigned int value)
 {
	char base34[34] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWX";
	char buffer[14];
	unsigned int offset = sizeof(buffer);

	buffer[--offset] = '\0';
	do {
		buffer[--offset] = base34[value % 34];
	} while (value /= 34);

	  return strdup(&buffer[offset]); 
  }

static long unsigned int base34dec(const char *text)
{
    return strtoul(text, NULL, 34);
}

int main()
{
    printf("The number(unsigned long integer) is %lu\n", base34dec("ABCDEF"));
    return 0;
}
Reply With Quote