Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Utf8 encode

Posted on 2013-11-21
2
Medium Priority
?
642 Views
Last Modified: 2013-11-22
Hi Experts,

Please I need help to convert string to utf8.

eg.:

cabeça - > cabe%C3%A7a
zé -> z%C3%A9
avó -> %C3%B3

I need to store the converted value in a variable.
I tried to use utf8encode(variable) but did not work.

var
  texto:string;
begin
   texto:=utf8encode('cabeça');
   showmessage(texto);
end;

But the result was "cabeça" and not "cabe%C3%A7a" as expected.

Please, some help.
Thanks
Alexandre
0
Comment
Question by:alpires
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Expert Comment

by:livestuff
ID: 39667564
UTF8Encode Converts a WideString value to a UTF8 string.



change your string var to WideString

http://docwiki.embarcadero.com/RADStudio/XE5/en/UTF-8_Conversion_Routines
0
 
LVL 28

Accepted Solution

by:
Sinisa Vuk earned 2000 total points
ID: 39667611
No, this is not native utf8 converting. This strings is for web... I'm right?
You need string to url encoding. Some examples here:
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_24870513.html
http://en.wikipedia.org/wiki/Percent-encoding#Current_standard

...but here is windows api function in wininet:
uses WinInet;
...
function EncodeUri(aSrc: String): String;
var
  Size: Cardinal;
  Buff: String;
begin
  Size := MAX_PATH;
  SetLength(Buff, Size);
  if not InternetCanonicalizeUrl(PChar(aSrc), PChar(Buff), Size, 0) then
    Size := 0;
  SetLength(Buff, Size);
  Result := Buff;
end;

Open in new window

0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

There is an easy way, in .NET, to centralize the treatment of all unexpected errors. First of all, instead of launching the application directly in a Form, you need first to write a Sub called Main, in a module. Then, set the Startup Object to th…
This article will show, step by step, how to integrate R code into a R Sweave document
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
Suggested Courses

650 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