* Encodes given character to a block. * @protected * @param {number} codePoint Unicode code point * @param {number} index Unicode code point index * @param {Chain} content Content to be encoded * @return {number[]|string|Uint8Array|Chain|null} Encoded block
(codePoint, index, content)
| 65 | * @return {number[]|string|Uint8Array|Chain|null} Encoded block |
| 66 | */ |
| 67 | performCharEncodeToBlock (codePoint, index, content) { |
| 68 | const caseSensitivity = this.getSettingValue('caseSensitivity') |
| 69 | |
| 70 | let alphabet = this.getSettingValue('alphabet') |
| 71 | if (!caseSensitivity) { |
| 72 | alphabet = alphabet.toLowerCase() |
| 73 | } |
| 74 | |
| 75 | let charIndex = alphabet.indexOfCodePoint(codePoint) |
| 76 | if (charIndex === -1) { |
| 77 | return null |
| 78 | } |
| 79 | |
| 80 | // This is a 1-based index |
| 81 | charIndex += 1 |
| 82 | |
| 83 | return charIndex.toString() |
| 84 | } |
| 85 | |
| 86 | /** |
| 87 | * Decodes given block to a character. |
nothing calls this directly
no test coverage detected