* default to UTF-8 as system code page in case nl_langinfo(CODESET) returns

an empty string

git-svn-id: trunk@19964 -
This commit is contained in:
Jonas Maebe 2012-01-04 16:06:27 +00:00
parent 33544c63d0
commit f287cf3f61

View File

@ -874,8 +874,18 @@ begin
end;
function GetStandardCodePage(const stdcp: TStandardCodePageEnum): TSystemCodePage;
var
langinfo: pchar;
begin
Result := iconv2win(ansistring(nl_langinfo(CODESET)))
langinfo:=nl_langinfo(CODESET);
{ there's a bug in the Mac OS X 10.5 libc (based on FreeBSD's)
that causes it to return an empty string of UTF-8 locales
-> patch up (and in general, UTF-8 is a good default on
Unix platforms) }
if not assigned(langinfo) or
(langinfo^=#0) then
langinfo:='UTF-8';
Result := iconv2win(ansistring(langinfo));
end;
{$ifdef FPC_HAS_CPSTRING}