Decode UTF8 String Function in Delphi/Pascal
2013-04-29
33 words
1 min read
function DecodeUtf8Str(const S: UTF8String): WideString;
var lenSrc, lenDst : Integer;
begin
lenSrc := Length(S);
if(lenSrc=0)then Exit;
lenDst := MultiByteToWideChar(CP_UTF8, 0, Pointer(S), lenSrc, nil, 0);
SetLength(Result, lenDst);
MultiByteToWideChar(CP_UTF8, 0, Pointer(S), lenSrc, Pointer(Result), lenDst);
end;
Authored By Jesse Lau
A freelancer living in New Zealand, engaged in website development and program trading. Ever won 1st ranking twice in the Dukascopy Strategy Contest. This article is licensed under a Creative Commons Attribution 4.0 International License.