-1

I know is %F0 %9F %8C %A0

but how can I convert this to be usable in Delphi ?

I tried several html encoders , but none give this result

my test

 for i := 1 to length(s) do
    result:= result+IntToHex(ord(s[i]),2);

but my result is D83CDF20

Toby Allen
  • 10,997
  • 11
  • 73
  • 124
multi pid
  • 77
  • 7
  • I think you need to be more specific about your set up. What, *exactly*, do you want to achieve? – Andreas Rejbrand Nov 29 '15 at 22:09
  • Putting `%F0%9F%8C%A0` in an HTML document will just give you the literal `%F0%9F%8C%A0`. What you're looking for isn't HTML encoding, that's why searching for HTML encoders didn't produce anything useful. Hint: what do you want to use this for? What might you call such an encoding, then? –  Nov 29 '15 at 22:13
  • i need to send with this encoding , the server waits for her. look my test for i := 1 to length(s) do result:= result+inttostr(ord(s[i])); @MartynA – multi pid Nov 29 '15 at 22:40
  • CP8 M: Perhaps you are looking to *URL* (not HTML) encode a string. – Andreas Rejbrand Nov 29 '15 at 22:41
  • Then put that in your q. Readers shouldn't have to guess what you're trying to do. – MartynA Nov 29 '15 at 22:41
  • Please don't fight us. Please tell us the back story, and let us tell you the right way to solve your problem. Please trust me when I tell you that you don't know how to solve it yet. – David Heffernan Nov 29 '15 at 22:43

1 Answers1

7

That is a simple UTF-8 encoding of this character. You can get the Delphi string using TEncoding like this:

var
  S: string;
begin
  S := TEncoding.UTF8.GetString(TBytes.Create($F0, $9F, $8C, $A0));
end;

or simply

S := '';

In case you want it the other way round:

var
  bytes: TBytes;
begin
  bytes := TEncoding.UTF8.GetBytes('');
end;

Or:

var
  S: UTF8String;
begin
  S := UTF8String('');
end;

Valid for Delphi 2009 and later.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
Uwe Raabe
  • 45,288
  • 3
  • 82
  • 130