DataPower issue
Last active
March 11, 2021 20:12
-
-
Save devinrhode2/a2bac31663287d8d107ed7d1b7112f2d to your computer and use it in GitHub Desktop.
normalize a 0xa0 non-breaking space character to ascii compatible encoding. For error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Error "Unable to parse JSON and generate JSONx: illegal character 0xa0 at offset 7164 of" from DataPower (sending email) | |
/* | |
results = {}; | |
[ | |
['wonky', String.fromCharCode(160)], | |
['basic', ' '], | |
].forEach(([label, str]) => { | |
['NFC', 'NFD', 'NFKC', 'NFKD'].forEach((uform) => { | |
[ | |
['esca', escape], | |
['enco', encodeURIComponent], | |
['btoa',btoa] | |
].forEach(([methodName, method]) => { | |
results[label+uform] = results[label+uform] || [] | |
results[label+uform].push( | |
method(str.normalize(uform)) | |
) | |
}) | |
}) | |
}) | |
results | |
*/ | |
/* | |
results = { | |
aA_guide: ['escape', 'encodeURIComp', 'btoa'] | |
}; | |
[ | |
['wonky', String.fromCharCode(160)], | |
['aThing', 'à'], | |
['basic', ' '], | |
].forEach(([label, originalStr]) => { | |
['NFC', 'NFD', 'NFKC', 'NFKD'].forEach((uform) => { | |
results[label+uform] = [ | |
escape, | |
encodeURIComponent, | |
btoa | |
].map((method) => { | |
var str; | |
try { | |
str = method(originalStr.normalize(uform)) | |
} finally { | |
return str | |
} | |
}) | |
}) | |
}) | |
results | |
*/ | |
results = { | |
//aA_guide: ['escape', 'encodeURIComp'] | |
}; | |
[ | |
['wonky', String.fromCharCode(160)+'à'], | |
].forEach(([label, originalStr]) => { | |
['NFC', 'NFD', 'NFKC', 'NFKD'].forEach((uform) => { | |
results[label+uform] = [ | |
escape, | |
encodeURIComponent | |
].map((method) => { | |
var str; | |
try { | |
str = method(originalStr.normalize(uform)) | |
} finally { | |
return str | |
} | |
}) | |
}) | |
}) | |
results |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NFKC seems best to avoid causing DataPower to crash with error of "Unable to parse JSON and generate JSONx: illegal character 0xa0 at offset 7164 of"