UNPKG

apphouse

Version:

Component library for React that uses observable state management and theme-able components.

15 lines (12 loc) 457 B
export const getAllHiddenCharacters = (inputValue: string) => { const hiddenCharacters: string[] = []; for (let i = 0; i < inputValue.length; i++) { const char: string = inputValue.charAt(i); // Check if the character is a control character (invisible or non-printable) if (char.charCodeAt(0) <= 31 || char.charCodeAt(0) === 127) { // hidden character found hiddenCharacters.push(char); } } return hiddenCharacters; };