roelbarreto / progressive-character-encoding

A new way to encode characters

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

progressive-character-encoding

A new way to encode characters

Rules

  1. [0-9,a-z] is a single character key -- i.e. a or 1
  2. [A-Z] will always followed by a character -- i.e. Aa or A1
  3. [A-Z] will always have a terminating character of [0-9,a-z] -- i.e. AAAa or ABC0

Best uses when shortening a hex value

Example of hex to pce: fa0012 = Fy0i

Hex Int Pce
fa 250 Fy
00 0 0
12 18 i

Example javascript code to generate index=key mapping

var chars =['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','j','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'],
chars2 = ['A','B','C','D','E','F','J','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'],
idx = 0,
ctr = 0,
ctr2 = 0,
ctr3 = 0;

while(ctr < chars.length){
	console.log(idx, chars[ctr]);
  idx++;
	ctr++;
}
ctr = 0;
while(ctr2 < chars2.length){
	console.log(idx, chars2[ctr2]+chars[ctr]);
	ctr = (ctr+1) % chars.length;
  if(ctr === 0){
  	ctr2++;
  }
  idx++;
}
ctr = 0;
while(ctr3 < chars2.length){
	ctr2 = 0;
  while(ctr2 < chars2.length){
    console.log(idx, chars2[ctr3]+chars2[ctr2]+chars[ctr]);
    ctr = (ctr+1) % chars.length;
    if(ctr === 0){
      ctr2++;
    }
    idx++;
  }
	ctr3++;
}
// 5306 = "ZZy"
// 25307 = "ZZz"
// 25307 count for 3 characters will be generated up to here 
// and so on...

About

A new way to encode characters

License:MIT License