|
@@ -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,6 +377,12 @@ 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 }
|
|
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));
|