• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 494
  • Last Modified:

how to convert a string from UTF-8 to unicode?

how to convert a string from UTF-8 to unicode? like the operation in Ultraedit32:
File->Conversions->UTF8 to Unicode
0
ArcherHu
Asked:
ArcherHu
1 Solution
 
ArcherHuAuthor Commented:
it's useful to convert data get form unicode database
0
 
geobulCommented:
Hi,

Try this:

var
  ws: WideString;
begin
  ...
  ws := WideString(YourString);
  ...

Regards, Geo
0
 
ArcherHuAuthor Commented:
no effect
0
 
mocartsCommented:
var
  pw: PWideChar;
  p: PAnsiChar;
begin
  p := ...
  GetMem(pw, strlen(p)*2+1);
  try
    if MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, p, strlen(p), pw, strlen(p)*2+1) = 0 then
      raise Exception.Create('Conversion filed');
...
  finally
    freemem(pw);
  end;
end;
0
 
CleanupPingCommented:
ArcherHu:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Independent Software Vendors: 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!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now