bcb-iconv added

This commit is contained in:
Kolan Sh 2013-02-21 11:23:52 +04:00
parent 7de78dd671
commit 6138b24d05
14 changed files with 444 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,152 @@
 <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{41947A47-0E83-4859-A1AC-01BC7C9091D9}</ProjectGuid>
<ProjectVersion>12.0</ProjectVersion>
<Config Condition="'$(Config)'==''">Debug</Config>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Debug' or '$(Cfg_1)'!=''">
<Cfg_1>true</Cfg_1>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Config)'=='Release' or '$(Cfg_2)'!=''">
<Cfg_2>true</Cfg_2>
<CfgParent>Base</CfgParent>
<Base>true</Base>
</PropertyGroup>
<PropertyGroup Condition="'$(Base)'!=''">
<Multithreaded>true</Multithreaded>
<PackageImports>vcl.bpi;rtl.bpi;bcbie.bpi;vclx.bpi;vclactnband.bpi;xmlrtl.bpi;bcbsmp.bpi;dbrtl.bpi;vcldb.bpi;vcldbx.bpi;bdertl.bpi;dsnap.bpi;dsnapcon.bpi;TeeUI.bpi;TeeDB.bpi;Tee.bpi;adortl.bpi;IndyCore.bpi;IndySystem.bpi;IndyProtocols.bpi;dbexpress.bpi;DbxCommonDriver.bpi;DataSnapIndy10ServerTransport.bpi;DataSnapProviderClient.bpi;DataSnapServer.bpi;DbxClientDriver.bpi;DBXInterBaseDriver.bpi;DBXMySQLDriver.bpi;dbxcds.bpi;DBXSybaseASEDriver.bpi;DBXSybaseASADriver.bpi;DBXOracleDriver.bpi;DBXMSSQLDriver.bpi;DBXInformixDriver.bpi;DBXDb2Driver.bpi;frxBDE12.bpi;frxcs12.bpi;frxDB12.bpi;frx12.bpi;frxDBX12.bpi;frxe12.bpi;frxTee12.bpi;fs12.bpi;fsADO12.bpi;fsBDE12.bpi;fsDB12.bpi;fsTee12.bpi;Jcl.bpi;JclVcl.bpi;JvCoreD12R.bpi;JvSystemD12R.bpi;JvStdCtrlsD12R.bpi;JvAppFrmD12R.bpi;JvBandsD12R.bpi;JvDBD12R.bpi;JvDlgsD12R.bpi;JvBDED12R.bpi;JvCmpD12R.bpi;JvCryptD12R.bpi;JvCtrlsD12R.bpi;JvCustomD12R.bpi;JvDockingD12R.bpi;JvDotNetCtrlsD12R.bpi;JvEDID12R.bpi;JvGlobusD12R.bpi;JvHMID12R.bpi;JvInterpreterD12R.bpi;JvJansD12R.bpi;JvManagedThreadsD12R.bpi;JvMMD12R.bpi;JvNetD12R.bpi;JvPageCompsD12R.bpi;JvPluginD12R.bpi;JvPrintPreviewD12R.bpi;JvRuntimeDesignD12R.bpi;JvTimeFrameworkD12R.bpi;JvValidatorsD12R.bpi;JvWizardD12R.bpi;JvXPCtrlsD12R.bpi;frxADO12.bpi</PackageImports>
<LinkPackageImports>rtl.bpi;vcl.bpi</LinkPackageImports>
<ProjectType>CppConsoleApplication</ProjectType>
<AllPackageLibs>rtl.lib;vcl.lib</AllPackageLibs>
<OutputExt>exe</OutputExt>
<BCC_IncludePath>libiconv\include;$(BCC_IncludePath)</BCC_IncludePath>
<DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>
<Defines>NO_STRICT;$(Defines)</Defines>
<DynamicRTL>true</DynamicRTL>
<UsePackages>true</UsePackages>
<IncludePath>K:\dev\cpp\bcb-iconv;$(CG_BOOST_ROOT)\boost\tr1\tr1;$(BDS)\include;$(BDS)\include\dinkumware;$(BDS)\include\vcl;$(CG_BOOST_ROOT);$(IncludePath)</IncludePath>
<ILINK_LibraryPath>libiconv;C:\libiconv\bin;C:\libiconv\lib;K:\dev\cpp\bcb-iconv;$(BDS)\lib;$(BDS)\lib\obj;$(BDS)\lib\psdk;$(ILINK_LibraryPath)</ILINK_LibraryPath>
<BCC_wpar>false</BCC_wpar>
<BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_1)'!=''">
<BCC_OptimizeForSpeed>false</BCC_OptimizeForSpeed>
<BCC_DisableOptimizations>true</BCC_DisableOptimizations>
<DCC_Optimize>false</DCC_Optimize>
<DCC_DebugInfoInExe>true</DCC_DebugInfoInExe>
<Defines>_DEBUG;$(Defines)</Defines>
<BCC_InlineFunctionExpansion>false</BCC_InlineFunctionExpansion>
<IntermediateOutputDir>Debug</IntermediateOutputDir>
<ILINK_DisableIncrementalLinking>true</ILINK_DisableIncrementalLinking>
<BCC_UseRegisterVariables>None</BCC_UseRegisterVariables>
<DCC_Define>DEBUG</DCC_Define>
<BCC_DebugLineNumbers>true</BCC_DebugLineNumbers>
<TASM_DisplaySourceLines>true</TASM_DisplaySourceLines>
<BCC_StackFrames>true</BCC_StackFrames>
<ILINK_LibraryPath>$(BDS)\lib\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>
<ILINK_FullDebugInfo>true</ILINK_FullDebugInfo>
<TASM_Debugging>Full</TASM_Debugging>
<BCC_SourceDebuggingOn>true</BCC_SourceDebuggingOn>
</PropertyGroup>
<PropertyGroup Condition="'$(Cfg_2)'!=''">
<Defines>NDEBUG;$(Defines)</Defines>
<IntermediateOutputDir>Release</IntermediateOutputDir>
<ILINK_LibraryPath>$(BDS)\lib\release;$(ILINK_LibraryPath)</ILINK_LibraryPath>
<TASM_Debugging>None</TASM_Debugging>
</PropertyGroup>
<ItemGroup>
<CppCompile Include="main.cpp">
<BuildOrder>0</BuildOrder>
</CppCompile>
<LibFiles Include="libiconv\libintl3-bcb.lib">
<IgnorePath>true</IgnorePath>
<BuildOrder>1</BuildOrder>
</LibFiles>
<LibFiles Include="libiconv\libcharset1-bcb.lib">
<IgnorePath>true</IgnorePath>
<BuildOrder>2</BuildOrder>
</LibFiles>
<LibFiles Include="libiconv\libiconv2-bcb.lib">
<IgnorePath>true</IgnorePath>
<BuildOrder>3</BuildOrder>
</LibFiles>
<BuildConfiguration Include="Base">
<Key>Base</Key>
</BuildConfiguration>
<BuildConfiguration Include="Release">
<Key>Cfg_2</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
<BuildConfiguration Include="Debug">
<Key>Cfg_1</Key>
<CfgParent>Base</CfgParent>
</BuildConfiguration>
</ItemGroup>
<Import Project="$(BDS)\Bin\CodeGear.Cpp.Targets" Condition="Exists('$(BDS)\Bin\CodeGear.Cpp.Targets')"/>
<ProjectExtensions>
<Borland.Personality>CPlusPlusBuilder.Personality.12</Borland.Personality>
<Borland.ProjectType>CppConsoleApplication</Borland.ProjectType>
<BorlandProject>
<CPlusPlusBuilder.Personality>
<VersionInfo>
<VersionInfo Name="IncludeVerInfo">False</VersionInfo>
<VersionInfo Name="AutoIncBuild">False</VersionInfo>
<VersionInfo Name="MajorVer">1</VersionInfo>
<VersionInfo Name="MinorVer">0</VersionInfo>
<VersionInfo Name="Release">0</VersionInfo>
<VersionInfo Name="Build">0</VersionInfo>
<VersionInfo Name="Debug">False</VersionInfo>
<VersionInfo Name="PreRelease">False</VersionInfo>
<VersionInfo Name="Special">False</VersionInfo>
<VersionInfo Name="Private">False</VersionInfo>
<VersionInfo Name="DLL">False</VersionInfo>
<VersionInfo Name="Locale">1049</VersionInfo>
<VersionInfo Name="CodePage">1251</VersionInfo>
</VersionInfo>
<VersionInfoKeys>
<VersionInfoKeys Name="CompanyName"/>
<VersionInfoKeys Name="FileDescription"/>
<VersionInfoKeys Name="FileVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="InternalName"/>
<VersionInfoKeys Name="LegalCopyright"/>
<VersionInfoKeys Name="LegalTrademarks"/>
<VersionInfoKeys Name="OriginalFilename"/>
<VersionInfoKeys Name="ProductName"/>
<VersionInfoKeys Name="ProductVersion">1.0.0.0</VersionInfoKeys>
<VersionInfoKeys Name="Comments"/>
</VersionInfoKeys>
<Debugging>
<Debugging Name="DebugSourceDirs"/>
</Debugging>
<Parameters>
<Parameters Name="RunParams"/>
<Parameters Name="Launcher"/>
<Parameters Name="UseLauncher">True</Parameters>
<Parameters Name="DebugCWD"/>
<Parameters Name="HostApplication"/>
<Parameters Name="RemoteHost"/>
<Parameters Name="RemotePath"/>
<Parameters Name="RemoteParams"/>
<Parameters Name="RemoteLauncher"/>
<Parameters Name="UseRemoteLauncher">False</Parameters>
<Parameters Name="RemoteCWD"/>
<Parameters Name="RemoteDebug">False</Parameters>
<Parameters Name="Debug Symbols Search Path"/>
<Parameters Name="LoadAllSymbols">True</Parameters>
<Parameters Name="LoadUnspecifiedSymbols">False</Parameters>
</Parameters>
<ProjectProperties>
<ProjectProperties Name="AutoShowDeps">False</ProjectProperties>
<ProjectProperties Name="ManagePaths">True</ProjectProperties>
<ProjectProperties Name="VerifyPackages">True</ProjectProperties>
</ProjectProperties>
</CPlusPlusBuilder.Personality>
</BorlandProject>
<ProjectFileVersion>12</ProjectFileVersion>
</ProjectExtensions>
</Project>

View File

@ -0,0 +1,141 @@
/* Copyright (C) 1999-2003 Free Software Foundation, Inc.
This file is part of the GNU LIBICONV Library.
The GNU LIBICONV Library is free software; you can redistribute it
and/or modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
The GNU LIBICONV Library is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU LIBICONV Library; see the file COPYING.LIB.
If not, write to the Free Software Foundation, Inc., 59 Temple Place -
Suite 330, Boston, MA 02111-1307, USA. */
/* When installed, this file is called "iconv.h". */
#ifndef _LIBICONV_H
#define _LIBICONV_H
#define _LIBICONV_VERSION 0x0109 /* version number: (major<<8) + minor */
#ifdef LIBICONV_STATIC
#define LIBICONV_DLL_EXPORTED
#else /* LIBICONV_STATIC */
#ifdef BUILDING_LIBICONV
#define LIBICONV_DLL_EXPORTED __declspec(dllexport)
#else
#define LIBICONV_DLL_EXPORTED __declspec(dllimport)
#endif
#endif /* LIBICONV_STATIC */
extern LIBICONV_DLL_EXPORTED int _libiconv_version; /* Likewise */
/* We would like to #include any system header file which could define
iconv_t, 1. in order to eliminate the risk that the user gets compilation
errors because some other system header file includes /usr/include/iconv.h
which defines iconv_t or declares iconv after this file, 2. when compiling
for LIBICONV_PLUG, we need the proper iconv_t type in order to produce
binary compatible code.
But gcc's #include_next is not portable. Thus, once libiconv's iconv.h
has been installed in /usr/local/include, there is no way any more to
include the original /usr/include/iconv.h. We simply have to get away
without it.
Ad 1. The risk that a system header file does
#include "iconv.h" or #include_next "iconv.h"
is small. They all do #include <iconv.h>.
Ad 2. The iconv_t type is a pointer type in all cases I have seen. (It
has to be a scalar type because (iconv_t)(-1) is a possible return value
from iconv_open().) */
/* Define iconv_t ourselves. */
#undef iconv_t
#define iconv_t libiconv_t
typedef void* iconv_t;
/* Get size_t declaration. */
#include <stddef.h>
/* Get errno declaration and values. */
#include <errno.h>
/* Some systems, like SunOS 4, don't have EILSEQ. Some systems, like BSD/OS,
have EILSEQ in a different header. On these systems, define EILSEQ
ourselves. */
#ifndef EILSEQ
#define EILSEQ
#endif
#ifdef __cplusplus
extern "C" {
#endif
/* Allocates descriptor for code conversion from encoding `fromcode' to
encoding `tocode'. */
#ifndef LIBICONV_PLUG
#define iconv_open libiconv_open
#endif
extern LIBICONV_DLL_EXPORTED iconv_t iconv_open (const char* tocode, const char* fromcode);
/* Converts, using conversion descriptor `cd', at most `*inbytesleft' bytes
starting at `*inbuf', writing at most `*outbytesleft' bytes starting at
`*outbuf'.
Decrements `*inbytesleft' and increments `*inbuf' by the same amount.
Decrements `*outbytesleft' and increments `*outbuf' by the same amount. */
#ifndef LIBICONV_PLUG
#define iconv libiconv
#endif
extern LIBICONV_DLL_EXPORTED size_t iconv (iconv_t cd, const char* * inbuf, size_t *inbytesleft, char* * outbuf, size_t *outbytesleft);
/* Frees resources allocated for conversion descriptor `cd'. */
#ifndef LIBICONV_PLUG
#define iconv_close libiconv_close
#endif
extern LIBICONV_DLL_EXPORTED int iconv_close (iconv_t cd);
#ifndef LIBICONV_PLUG
/* Nonstandard extensions. */
/* Control of attributes. */
#define iconvctl libiconvctl
extern LIBICONV_DLL_EXPORTED int iconvctl (iconv_t cd, int request, void* argument);
/* Requests for iconvctl. */
#define ICONV_TRIVIALP 0 /* int *argument */
#define ICONV_GET_TRANSLITERATE 1 /* int *argument */
#define ICONV_SET_TRANSLITERATE 2 /* const int *argument */
#define ICONV_GET_DISCARD_ILSEQ 3 /* int *argument */
#define ICONV_SET_DISCARD_ILSEQ 4 /* const int *argument */
/* Listing of locale independent encodings. */
#define iconvlist libiconvlist
extern LIBICONV_DLL_EXPORTED void iconvlist (int (*do_one) (unsigned int namescount,
const char * const * names,
void* data),
void* data);
/* Support for relocatable packages. */
/* Sets the original and the current installation prefix of the package.
Relocation simply replaces a pathname starting with the original prefix
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
extern LIBICONV_DLL_EXPORTED void libiconv_set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix);
#endif
#ifdef __cplusplus
}
#endif
#endif /* _LIBICONV_H */

View File

@ -0,0 +1,56 @@
/* Copyright (C) 2003 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
The GNU CHARSET Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU CHARSET Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with the GNU CHARSET Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#ifndef _LIBCHARSET_H
#define _LIBCHARSET_H
#ifdef LIBCHARSET_STATIC
#define LIBCHARSET_DLL_EXPORTED
#else /* LIBCHARSET_STATIC */
#ifdef BUILDING_LIBCHARSET
#define LIBCHARSET_DLL_EXPORTED __declspec(dllexport)
#else
#define LIBCHARSET_DLL_EXPORTED __declspec(dllimport)
#endif
#endif /* LIBCHARSET_STATIC */
#include <localcharset.h>
#ifdef __cplusplus
extern "C" {
#endif
/* Support for relocatable packages. */
/* Sets the original and the current installation prefix of the package.
Relocation simply replaces a pathname starting with the original prefix
by the corresponding pathname with the current prefix instead. Both
prefixes should be directory names without trailing slash (i.e. use ""
instead of "/"). */
extern LIBCHARSET_DLL_EXPORTED void libcharset_set_relocation_prefix (const char *orig_prefix,
const char *curr_prefix);
#ifdef __cplusplus
}
#endif
#endif /* _LIBCHARSET_H */

View File

@ -0,0 +1,51 @@
/* Determine a canonical name for the current locale's character encoding.
Copyright (C) 2000-2003 Free Software Foundation, Inc.
This file is part of the GNU CHARSET Library.
This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Library General Public License as published
by the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
USA. */
#ifndef _LOCALCHARSET_H
#define _LOCALCHARSET_H
#ifdef LIBCHARSET_STATIC
#define LIBCHARSET_DLL_EXPORTED
#else /* LIBCHARSET_STATIC */
#ifdef BUILDING_LIBCHARSET
#define LIBCHARSET_DLL_EXPORTED __declspec(dllexport)
#else
#define LIBCHARSET_DLL_EXPORTED __declspec(dllimport)
#endif
#endif /* LIBCHARSET_STATIC */
#ifdef __cplusplus
extern "C" {
#endif
/* Determine the current locale's character encoding, and canonicalize it
into one of the canonical names listed in config.charset.
The result must not be freed; it is statically allocated.
If the canonical name cannot be determined, the result is a non-canonical
name. */
extern LIBCHARSET_DLL_EXPORTED const char * locale_charset (void);
#ifdef __cplusplus
}
#endif
#endif /* _LOCALCHARSET_H */

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

44
cpp/bcb-iconv/main.cpp Normal file
View File

@ -0,0 +1,44 @@
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <tchar.h>
//---------------------------------------------------------------------------
#include <stdio.h>
#include <iconv.h>
#include <errno.h>
//#include <err.h>
#pragma argsused
int _tmain(int argc, _TCHAR* argv[])
{
iconv_t cd;
size_t k, f, t;
int se;
const char *code = "Âîïðîñ!";
const char* in = code;
char buf[100];
char* out = buf;
cd = iconv_open("cp1251", "koi8-r");
if( cd == (iconv_t)(-1) )
//err( 1, "iconv_open" );
fprintf (stderr, "iconv_open");
f = strlen(code);
t = sizeof buf;
memset( &buf, 0, sizeof buf );
errno = 0;
k = iconv(cd, &in, &f, &out, &t);
se = errno;
printf( "converted: %u,error=%d\n", (unsigned) k, se );
printf("string: %s\n", buf);
iconv_close(cd);
system ("pause");
return 0;
}
//---------------------------------------------------------------------------