I extract javascript code from PDF, but it is converted octal escape sequences.
I want to convert it to normal JavaScript code.
\040\040\040\040\146\165\156\143\164\151\157\156\040\163\167\050\051\17....
Please advise me.
I extract javascript code from PDF, but it is converted octal escape sequences.
I want to convert it to normal JavaScript code.
\040\040\040\040\146\165\156\143\164\151\157\156\040\163\167\050\051\17....
Please advise me.
You can use unicode_escape
encoding:
In Python 2.x:
>>> r'\040\040\040\040\146\165\156\143\164\151\157\156'.decode('unicode-escape')
u' function'
In Python 3.x:
>>> br'\040\040\040\040\146\165\156\143\164\151\157\156'.decode('unicode-escape')
' function'
This works for both Python 2.x and 3.x:
>>> b'\040\040\040\040\146\165\156\143\164\151\157\156\040\163\167'.decode('utf-8')
' function sw'