Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

expected hexadecimal digit

When I pass a file path, such as 'C:\u01\oracle\fmw_11114\data\proj\folder\name 09022014.txt, from java controller to a javascript script, it causes the error 'Expected hexadecimal Digit'.

This path is read from file-system and passed to the script directly and I can not escape the backslash '\' in the string before passing it to the script. Any ideas how to solve the problem?

if(document.getElementById('hdnA').value == 'ALR') {
     alert('ERROR: ' + '${arch}' + ' file not found.')
}
like image 854
hekomobile Avatar asked Feb 13 '26 22:02

hekomobile


2 Answers

The error message is a good indicator to what went wrong.

Unicode characters can be passed literally to a script using the format: \uXXXX (Where XXXX represent the code for the specific character).

Your path includes a folder whose name starts with U, so the path string contains the the literal control characters for literal Unicode character insertion (\u).

An easy workaround would be passing the file path with forward slashes instead:

'C:/u01/oracle/fmw_11114/data/proj/folder/name 09022014.txt'

I ran into the same issue with my Java application, which tried inserting a script dynamically with path values in the element. Changing my backslashes to forward slashes resolved the issue for me.

like image 101
Shy Alexander Tamir Avatar answered Feb 15 '26 10:02

Shy Alexander Tamir


Salam! Use this regexp:

patt=/\\/g;
str = str.replace(patt,"\\\\")

this worked for me;

like image 43
hhaseli Avatar answered Feb 15 '26 11:02

hhaseli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!