?
Solved

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

Posted on 2011-04-27
4
Medium Priority
?
1,725 Views
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.
0
Comment
Question by:MissManal
4 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 35481137
The following functions will help you:
function StringToHex(S: String): String;
var j: Integer;
begin
  Result:= '';
  for J := 1 to length (S) do
    Result:= Result+IntToHex(ord(S[J]),2);
end;

function HexToString(S: String): String;
var J: Integer;
begin
  Result:= '';
  for J := 1 to length (S) do
    if i mod 2 = 0 then
      Result := Result + Char(StrToInt('$'+S[J-1]+S[J]));
end;

Open in new window

0
 

Author Comment

by:MissManal
ID: 35481191
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
http://www.utf8-chartable.de/unicode-utf8-table.pl
0
 
LVL 1

Expert Comment

by:karagunes
ID: 35482157
Add HTTPApp to your uses and try this:

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

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 35484872

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

var
  MyString: UTF8String;
begin
  ......
  MyString := UTF8Encode(YourUnicodeString);
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

839 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