Instead of having a database of combinable characters, the new algorithm uses bit-wise to detect the crossing characters.
A character is converted into 12-bit number of 3 groups of format (single, bold, double).
Each group contains 4 bits representing 4 directions: [bottom, top, right, left]
DOUBLE SINGLE
╠═══════╣ ├───────┤ B: Bottom
┌─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┬─┐ T: Top
│B│T│R│L│B│T│R│L│B│T│R│L│ R: Right
└─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┴─┘ L: Left
┣━━━━━━━┫
BOLD
2 crossing characters at a cell will be combined with or operator (inner_mask).
Equivalent 4 surrounding characters of the 2 are also combined with or operator (outer_mask).
Then, inner_mask combines with outer_mask with and operator.
The result will be decoded into characters again and that is the crossing point character.
This also allows complex combinations of single-bold and single-double chars to connect
╓───────┒
║ ┃
╟───────┨
║ ┃
╙───────┚
TODO: new complex combination characters (such as ╓) are not used as possible surrounding yet.
Instead of having a database of combinable characters, the new algorithm uses bit-wise to detect the crossing characters.
A character is converted into 12-bit number of 3 groups of format (single, bold, double). Each group contains 4 bits representing 4 directions: [bottom, top, right, left]
or
operator (inner_mask).or
operator (outer_mask).inner_mask
combines withouter_mask
withand
operator.This also allows complex combinations of single-bold and single-double chars to connect
TODO: new complex combination characters (such as
╓
) are not used as possible surrounding yet.