Solved

Utf8 encode

Posted on 2013-11-21
2
588 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
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 26

Accepted Solution

by:
Sinisa Vuk earned 500 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
word0 challenge 3 100
can't find the executable in Simulator 1 100
Firemonkey android show image from resource ? 1 46
Work with App store 7 68
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Navigation is an important part of web design from a usability perspective. But it is often a pain when it comes to a developer’s perspective. By navigation, it often means menuing. This is less theory and more practical of how to get a specific gro…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

840 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