We help IT Professionals succeed at work.

unicode characters to UTF-8(Hex)

MissManal
MissManal asked
on
Medium Priority
893 Views
Last Modified: 2012-08-14
Hi all,

I am trying to make my application compatible with international languages and I am stuck with this problem.

I'm trying to pass Unicode string as a URL  parameter but It need to be converted to HEX UTF-8 string in order to pass it.

Anyone could help me to convert unicode string to HEX UTF8?

Thank you.
Comment
Watch Question

Commented:
try the below code,

function urlencode(c:char):string;
begin
result:='%'+inttohex(ord(c),2);
end;

and for a complete string you can use:

function urlencodestring(const s:string):string;
var
i: integer;
begin
result:='';
for i:=1 to length(s) do
result:=result+urlencode(s[i]);
end;

and then you can use it easily like

edit2.text:=urlencodestring(edit1.text);

Open in new window


Also try using,

TEncoding.Unicode.GetString( MyByteArray );

Open in new window



Source: google
Software Engineer
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.