HELLLLLLP :( HOW do i convert a unicode characters to its HEX UTF-8 String?

Posted on 2011-04-27
Last Modified: 2012-05-11
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 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.
Question by:MissManal
    LVL 24

    Expert Comment

    The following functions will help you:
    function StringToHex(S: String): String;
    var j: Integer;
      Result:= '';
      for J := 1 to length (S) do
        Result:= Result+IntToHex(ord(S[J]),2);
    function HexToString(S: String): String;
    var J: Integer;
      Result:= '';
      for J := 1 to length (S) do
        if i mod 2 = 0 then
          Result := Result + Char(StrToInt('$'+S[J-1]+S[J]));

    Open in new window


    Author Comment

    This code is only converting the unicode string to/from HEX !!! Not to UTF-8

    Still from Unicode to/from UTF-8 is missing.

    see this link
    LVL 1

    Expert Comment

    Add HTTPApp to your uses and try this:

       myVar: UnicodeString;
       myVar := HttpEncode(myVar);
       // myVar is now http encoded
       // you can now send it over internet
    LVL 32

    Accepted Solution


    Why don't you just use UTF8Encode() function. Its already provided in Delphi

      MyString: UTF8String;
      MyString := UTF8Encode(YourUnicodeString);

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
    Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now