mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-08 13:06:17 +02:00
* removed Darwin/Solaris-specific code and fixed all issues by calling
setlocale(LC_ALL,'') per POSIX, which initialises the langinfo stuff based on the environment variables (some OS'es do that automatically, but at least Darwin and Solaris don't) git-svn-id: trunk@7672 -
This commit is contained in:
parent
62b3b307e0
commit
7b47ebff6b
@ -58,27 +58,32 @@ function towlower(__wc:wint_t):wint_t;cdecl;external libiconvname name 'towlower
|
|||||||
function towupper(__wc:wint_t):wint_t;cdecl;external libiconvname name 'towupper';
|
function towupper(__wc:wint_t):wint_t;cdecl;external libiconvname name 'towupper';
|
||||||
function wcscoll (__s1:pwchar_t; __s2:pwchar_t):cint;cdecl;external libiconvname name 'wcscoll';
|
function wcscoll (__s1:pwchar_t; __s2:pwchar_t):cint;cdecl;external libiconvname name 'wcscoll';
|
||||||
function strcoll (__s1:pchar; __s2:pchar):cint;cdecl;external libiconvname name 'strcoll';
|
function strcoll (__s1:pchar; __s2:pchar):cint;cdecl;external libiconvname name 'strcoll';
|
||||||
|
function setlocale(category: cint; locale: pchar): pchar; cdecl; external clib name 'setlocale';
|
||||||
|
|
||||||
const
|
const
|
||||||
{$ifdef linux}
|
{$ifdef linux}
|
||||||
__LC_CTYPE = 0;
|
__LC_CTYPE = 0;
|
||||||
|
LC_ALL = 6;
|
||||||
_NL_CTYPE_CLASS = (__LC_CTYPE shl 16);
|
_NL_CTYPE_CLASS = (__LC_CTYPE shl 16);
|
||||||
_NL_CTYPE_CODESET_NAME = (_NL_CTYPE_CLASS)+14;
|
_NL_CTYPE_CODESET_NAME = (_NL_CTYPE_CLASS)+14;
|
||||||
CODESET = _NL_CTYPE_CODESET_NAME;
|
CODESET = _NL_CTYPE_CODESET_NAME;
|
||||||
{$else linux}
|
{$else linux}
|
||||||
{$ifdef darwin}
|
{$ifdef darwin}
|
||||||
CODESET = 0;
|
CODESET = 0;
|
||||||
|
LC_ALL = 0;
|
||||||
{$else darwin}
|
{$else darwin}
|
||||||
{$ifdef FreeBSD} // actually FreeBSD5. internationalisation is afaik not default on 4.
|
{$ifdef FreeBSD} // actually FreeBSD5. internationalisation is afaik not default on 4.
|
||||||
__LC_CTYPE = 0;
|
__LC_CTYPE = 0;
|
||||||
|
LC_ALL = 0;
|
||||||
_NL_CTYPE_CLASS = (__LC_CTYPE shl 16);
|
_NL_CTYPE_CLASS = (__LC_CTYPE shl 16);
|
||||||
_NL_CTYPE_CODESET_NAME = (_NL_CTYPE_CLASS)+14;
|
_NL_CTYPE_CODESET_NAME = (_NL_CTYPE_CLASS)+14;
|
||||||
CODESET = 0; // _NL_CTYPE_CODESET_NAME;
|
CODESET = 0; // _NL_CTYPE_CODESET_NAME;
|
||||||
{$else freebsd}
|
{$else freebsd}
|
||||||
{$ifdef solaris}
|
{$ifdef solaris}
|
||||||
CODESET=49;
|
CODESET=49;
|
||||||
|
LC_ALL = 6;
|
||||||
{$else}
|
{$else}
|
||||||
{$error lookup the value of CODESET in /usr/include/langinfo.h for your OS }
|
{$error lookup the value of CODESET in /usr/include/langinfo.h, and the value of LC_ALL in /usr/include/locale.h for your OS }
|
||||||
// and while doing it, check if iconv is in libc, and if the symbols are prefixed with iconv_ or libiconv_
|
// and while doing it, check if iconv is in libc, and if the symbols are prefixed with iconv_ or libiconv_
|
||||||
{$endif solaris}
|
{$endif solaris}
|
||||||
{$endif FreeBSD}
|
{$endif FreeBSD}
|
||||||
@ -372,18 +377,17 @@ end;
|
|||||||
initialization
|
initialization
|
||||||
SetCWideStringManager;
|
SetCWideStringManager;
|
||||||
initcriticalsection(iconv_lock);
|
initcriticalsection(iconv_lock);
|
||||||
|
|
||||||
|
{ you have to call setlocale(LC_ALL,'') to initialise the langinfo stuff }
|
||||||
|
{ with the information from the environment variables according to POSIX }
|
||||||
|
{ (some OSes do this automatically, but e.g. Darwin and Solaris don't) }
|
||||||
|
setlocale(LC_ALL,'');
|
||||||
|
|
||||||
{ init conversion tables }
|
{ init conversion tables }
|
||||||
{$if not defined(darwin) and not defined(solaris)}
|
|
||||||
iconv_wide2ansi:=iconv_open(nl_langinfo(CODESET),unicode_encoding);
|
iconv_wide2ansi:=iconv_open(nl_langinfo(CODESET),unicode_encoding);
|
||||||
iconv_ansi2wide:=iconv_open(unicode_encoding,nl_langinfo(CODESET));
|
iconv_ansi2wide:=iconv_open(unicode_encoding,nl_langinfo(CODESET));
|
||||||
iconv_ucs42ansi:=iconv_open(nl_langinfo(CODESET),'UCS4');
|
iconv_ucs42ansi:=iconv_open(nl_langinfo(CODESET),'UCS4');
|
||||||
iconv_ansi2ucs4:=iconv_open('UCS4',nl_langinfo(CODESET));
|
iconv_ansi2ucs4:=iconv_open('UCS4',nl_langinfo(CODESET));
|
||||||
{$else darwin or solaris}
|
|
||||||
iconv_wide2ansi:=iconv_open('UTF-8',unicode_encoding);
|
|
||||||
iconv_ansi2wide:=iconv_open(unicode_encoding,'UTF-8');
|
|
||||||
iconv_ucs42ansi:=iconv_open('UTF-8','UCS4');
|
|
||||||
iconv_ansi2ucs4:=iconv_open('UCS4','UTF-8');
|
|
||||||
{$endif darwin or solaris}
|
|
||||||
finalization
|
finalization
|
||||||
donecriticalsection(iconv_lock);
|
donecriticalsection(iconv_lock);
|
||||||
iconv_close(iconv_ansi2wide);
|
iconv_close(iconv_ansi2wide);
|
||||||
|
Loading…
Reference in New Issue
Block a user