Hi, I am trying to convert the special character o...
# suitescript
t
Hi, I am trying to convert the special character on the customer name plgc_test period< but when it transpose to PDF report (we generate report using XML) it returns the character entities (see image). My code is
customerName.replace(/&/g, '&#38;').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '&quot;').replace(/'/g, '&apos;');
b
what does the rest of the code look like
what you shared doesnt do anything by itself
t
Copy code
function convertSpecialCharactersForFileName(name) {

    if(name) {

        name = name.replace(/&/g, '&#38;').replace(/</g, '&#60;').replace(/>/g, '>').replace(/"/g, '&quot;').replace(/'/g, '&apos;');
        log.debug('nameReplaced', name);
    }

    return name;
}
this the function.. just replacing special characters
b
thats not the order, nor the actual predefined entities you want to use
Copy code
convertSpecialCharactersForFileName('nameplgc_test period<')
returns
"nameplgc_test period&#60;"
you want it to return
"nameplgc_test period<"
t
good point on this @battk I'll check this again