Reputation: 3001
My Oracle backend procedure needs to encode some encrypted values and pass them to an ASP .NET MVC application through the URL. I already know about utl_i18n.escape_reference
and utl_url.escape
, but they don't seem to be able to encode the text in the same way as the ASP.NET application.
The problem is that the + does not get encoded and comes as a space when I debug the ASP.NET application.
The following 3 statements all return '+
' when I run them in TOAD, whereas I'm expecting "%2B
":
select utl_i18n.escape_reference('+') from dual
select utl_url.escape('+') from dual
select utl_i18n.escape_reference(utl_url.escape('+')) from dual
Perhaps it has to do with the character set? How can I check the character set in IIS?
Upvotes: 1
Views: 10952
Reputation: 52893
It's because +
is a reserved character for UTL_URL.ESCAPE()
; to quote:
The reserved characters consist of:
- Semi-colon (;) slash (/), question mark (?), colon (:), at sign (@), ampersand (&), equals sign (=), plus sign (+), dollar sign ($), and comma (,)
Many of the reserved characters are used as delimiters in the URL. You should escape characters beyond those listed here by using escape_url. Also, to use the reserved characters in the name-value pairs of the query string of a URL, those characters must be escaped separately.
There is a Boolean parameter escape_reserved_characters
, which allows you to escape the +
:
Indicates whether the URL reserved characters should be escaped. If set to TRUE, both the reserved and illegal URL characters are escaped. Otherwise, only the illegal URL characters are escaped. The default value is FALSE.
You cannot use Boolean's in SQL, so you would have to do this in PL/SQL
declare
l_escaped_url varchar2(10);
begin
l_escaped_url := utl_url.escape('+', True);
dbms_output.put_line(l_escaped_url);
end;
/
Upvotes: 3