Skip to Main Content

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, mahmoud.

Asked: December 10, 2016 - 5:06 pm UTC

Last updated: December 13, 2016 - 3:13 am UTC

Version: oracle database 11g (11.1.2)

Viewed 1000+ times

You Asked

Hi ,
i'm trying to send sms using database , and my problem is in double encoding .
i want to send Russian letters , English working for me fine . only the way of that is to translate the text using http://www.freeformatter.com/url-encoder.html#ad-output
is there in option to create a function in database solve my problem ?
i want convert как дела ?
to %D0%BA%D0%B0%D0%BA+%D0%B4%D0%B5%D0%BB%D0%B0+%3F%0D%0A%D0%BA%D0%B0%D0%BA+%D0%B4%D0%B5%D0%BB%D0%B0+%3F%0D%0A

Thanks & best Regards

and Connor said...

Something like this perhaps

set serveroutput on
declare
  str varchar2(100) := 'как дела';
  res varchar2(255);
begin
  for i in 1 .. length(str) loop
    res := res || to_char(ascii(substr(str,i,1)),'fmxxxx');
  end loop;
  dbms_output.put_line(res);
end;
/


You can adjust the facility to include % etc.

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

i out need it like this

mahmoud Yousef, December 11, 2016 - 11:40 pm UTC

Hi , Thank you very much
but when i try the function its return :
d0bad0b0d0ba20d0b4d0b5d0bbd0b0

and i want it return like this :
%D0%BA%D0%B0%D0%BA+%D0%B4%D0%B5%D0%BB%D0%B0

for example + here mean space

Connor McDonald
December 12, 2016 - 1:07 am UTC

My last line was:

"You can adjust the facility to include % etc."

I mean seriously - look at the code I've written. A substr command and an if-then and the job would be done.

If you *really* need the code so you can just cut-paste it, then fine - let me know...but if you're in the habit of just cut-pasting code from the web, then eventually one day ... someone will give you something to cut-paste which will damage your database without you even knowing...Its a sure-fire way to get hacked.

mahmoud Yousef, December 12, 2016 - 12:15 pm UTC

I tried but not success , kindly help me with the code .

Connor McDonald
December 13, 2016 - 3:13 am UTC

Let's see your code - and I'll try help out

More to Explore

DBMS_OUTPUT

More on PL/SQL routine DBMS_OUTPUT here