Regarding to [url=http://forum.pspad.com/read.php?6,64691,64820,page=2#msg-64820]the topic[/url]. MSDN: -------------------------------------------------------------------------------- _Windows XP and later:_ MB_ERR_INVALID_CHARS is the only dwFlags value supported by Code page 65001 (UTF-8).--------------------------------------------------------------------------------
So you can pass MB_ERR_INVALID_CHARS to our function and get the same behavior as from the Delphi built-in: const MB_ERR_INVALID_CHARS = 8; function Utf8Decode(const Source: UTF8String): WideString; // my function var L: Integer; Dest: WideString; begin L := Length(Source); SetLength(Dest, L); SetLength(Dest, MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, Pointer(Source), L, Pointer(Dest), L)); Result := Dest; end; begin if Utf8Decode(Text) = '' then // treat as ANSI end; This will work only since Windows XP and later, Windows 2000 requires dwFlags=0. -- <http://forum.pspad.com/read.php?4,45099,64824> PSPad freeware editor http://www.pspad.com