public final class Base46 extends Object
Base47 encoding is best fit for encoding varible length numbers in JavaScript strings.
47 = (int)(93 / 2), where 94 is the number of ASCII characters representable in JavaScript string without escaping. These characters are encoded by one byte in UTF-8 charset. All other character require either escaping or two or more bytes in UTF-8.
We divide 93 by 2 for the following trick. Representing integers takes 5 bytes in Base93. However, we often need smaller integers that might be represented by one or two bytes. By each Base93 digit we can encode both part of the number and a flag indicating whether the number contains one more digit.
Modifier and Type | Method and Description |
---|---|
static int |
decode(CharFlow seq) |
static int |
decodeDigit(char c) |
static long |
decodeLong(CharFlow seq) |
static int |
decodeUnsigned(CharFlow seq) |
static long |
decodeUnsignedLong(CharFlow seq) |
static void |
encode(StringBuilder sb,
int number) |
static void |
encode(StringBuilder sb,
long number) |
static char |
encodeDigit(int digit) |
static void |
encodeUnsigned(StringBuilder sb,
int number) |
static void |
encodeUnsigned(StringBuilder sb,
long number) |
public static void encodeUnsigned(StringBuilder sb, int number)
public static void encode(StringBuilder sb, int number)
public static void encodeUnsigned(StringBuilder sb, long number)
public static void encode(StringBuilder sb, long number)
public static int decodeUnsigned(CharFlow seq)
public static int decode(CharFlow seq)
public static long decodeUnsignedLong(CharFlow seq)
public static long decodeLong(CharFlow seq)
public static char encodeDigit(int digit)
public static int decodeDigit(char c)
Copyright © 2019. All rights reserved.