Create rough solution for handling non-printing characters in results

This commit is contained in:
marcnjaramillo
2021-10-05 19:37:14 -07:00
parent 9f0a975a0c
commit 4783ad6bff

View File

@@ -10,12 +10,28 @@ interface Props {
export default function RawTableValue(props: Props): JSX.Element {
const v = props.value;
const codes: { [key: string]: any } = {
'\n': 'U+000A',
'\b': 'U+2084',
'\0': 'U+0000'
};
if (
typeof v === 'string'
|| typeof v === 'number'
|| typeof v === 'boolean'
) {
return <span>{v.toString()}</span>;
const text = v.toString();
const newVal = text.split('');
for (let i = 0; i < newVal.length; i++) {
for (const char in codes) {
if (char === newVal[i]) {
newVal[i] = codes[char];
}
}
}
const cleanVal = newVal.join('');
return <span>{cleanVal}</span>;
}
return renderLocation(v.url, v.label, props.databaseUri);