NCBI C++ ToolKit
Macros | Enumerations | Functions | Variables
iconv.c File Reference

Handle character conversions to/from server. More...

#include <config.h>
#include <stdarg.h>
#include <stdio.h>
#include <assert.h>
#include <freetds/tds.h>
#include <freetds/iconv.h>
#include "encodings.h"
+ Include dependency graph for iconv.c:

Go to the source code of this file.

Go to the SVN repository for this file.

Macros

#define CHARSIZE(charset)
 
#define TDS_ICONV_ENCODING_TABLES
 
#define CHUNK_ALLOC   4
 

Enumerations

enum  { POS_ISO1 , POS_UTF8 , POS_UCS2LE , POS_UCS2BE }
 

Functions

static int collate2charset (int sql_collate, int lcid)
 
static size_t skip_one_input_sequence (iconv_t cd, const TDS_ENCODING *charset, const char **input, size_t *input_size)
 Move the input sequence pointer to the next valid position. More...
 
static int tds_iconv_info_init (TDSICONV *char_conv, int client_canonical, int server_canonical)
 Open iconv descriptors to convert between character sets (both directions). More...
 
static int tds_iconv_init (void)
 Initialize charset searching for UTF-8, UCS-2 and ISO8859-1. More...
 
static int tds_canonical_charset (const char *charset_name)
 Determine canonical iconv character set. More...
 
static void _iconv_close (iconv_t *cd)
 
static void tds_iconv_info_close (TDSICONV *char_conv)
 
static const char * tds_set_iconv_name (int charset)
 Get iconv name given canonic. More...
 
static void tds_iconv_reset (TDSICONV *conv)
 
int tds_iconv_alloc (TDSCONNECTION *conn)
 Allocate iconv stuff. More...
 
TDSRET tds_iconv_open (TDSCONNECTION *conn, const char *charset, int use_utf16)
 
void tds_iconv_close (TDSCONNECTION *conn)
 
void tds_iconv_free (TDSCONNECTION *conn)
 
static void tds_iconv_err (TDSSOCKET *tds, int err)
 
size_t tds_iconv (TDSSOCKET *tds, TDSICONV *conv, TDS_ICONV_DIRECTION io, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
 Wrapper around iconv(3). More...
 
static TDSICONVtds_iconv_get_info (TDSCONNECTION *conn, int canonic_client, int canonic_server)
 Get a iconv info structure, allocate and initialize if needed. More...
 
TDSICONVtds_iconv_get (TDSCONNECTION *conn, const char *client_charset, const char *server_charset)
 
static void tds_srv_charset_changed_num (TDSCONNECTION *conn, int canonic_charset_num)
 
void tds_srv_charset_changed (TDSCONNECTION *conn, const char *charset)
 
void tds7_srv_charset_changed (TDSCONNECTION *conn, int sql_collate, int lcid)
 
static int lookup_canonic (const CHARACTER_SET_ALIAS aliases[], const char *charset_name)
 
const char * tds_canonical_charset_name (const char *charset_name)
 Determine canonical iconv character set name. More...
 
TDSICONVtds_iconv_from_collate (TDSCONNECTION *conn, TDS_UCHAR collate[5])
 Get iconv information from a LCID (to support different column encoding under MSSQL2K) More...
 

Variables

static const char * iconv_names [sizeof(canonic_charsets)/sizeof(canonic_charsets[0])]
 
static int iconv_initialized = 0
 
static const char * ucs2name
 

Detailed Description

Handle character conversions to/from server.

Definition in file iconv.c.

Macro Definition Documentation

◆ CHARSIZE

#define CHARSIZE (   charset)
Value:
( ((charset)->min_bytes_per_char == (charset)->max_bytes_per_char )? \
(charset)->min_bytes_per_char : 0 )

Definition at line 45 of file iconv.c.

◆ TDS_ICONV_ENCODING_TABLES

#define TDS_ICONV_ENCODING_TABLES

Definition at line 64 of file iconv.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
POS_ISO1 
POS_UTF8 
POS_UCS2LE 
POS_UCS2BE 

Definition at line 75 of file iconv.c.

Function Documentation

◆ tds_iconv_alloc()

int tds_iconv_alloc ( TDSCONNECTION conn)

Allocate iconv stuff.

Returns
0 for success

Definition at line 286 of file iconv.c.

References assert, client2server_chardata, conn, i, initial_char_conv_count, tds_iconv_reset(), tds_new, tds_new0, and TDS_ZERO_FREE.

◆ tds_iconv_init()

static int tds_iconv_init ( void  )
static

Initialize charset searching for UTF-8, UCS-2 and ISO8859-1.

Definition at line 82 of file iconv.c.

References assert, i, ICONV_CONST, iconv_names, POS_ISO1, POS_UCS2BE, POS_UCS2LE, POS_UTF8, util::strcmp(), util::strncmp(), TDS_DBG_INFO1, tds_sys_iconv(), tds_sys_iconv_close(), tds_sys_iconv_open(), tdsdump_log, and ucs2name.

Referenced by tds_iconv_open().

◆ tds_iconv_reset()

static void tds_iconv_reset ( TDSICONV conv)
static

◆ tds_set_iconv_name()

static const char* tds_set_iconv_name ( int  charset)
static

Get iconv name given canonic.

Definition at line 199 of file iconv.c.

References assert, i, iconv_initialized, iconv_mtx, iconv_names, NULL, POS_ISO1, POS_UTF8, tds_mutex_lock, tds_mutex_unlock, tds_sys_iconv_close(), tds_sys_iconv_open(), and ucs2name.

Referenced by tds_iconv_info_init().

Variable Documentation

◆ iconv_initialized

int iconv_initialized = 0
static

Definition at line 69 of file iconv.c.

Referenced by tds_iconv_open(), and tds_set_iconv_name().

◆ iconv_names

const char* iconv_names[sizeof(canonic_charsets)/sizeof(canonic_charsets[0])]
static

Definition at line 68 of file iconv.c.

Referenced by tds_iconv(), tds_iconv_info_init(), tds_iconv_init(), and tds_set_iconv_name().

◆ ucs2name

const char* ucs2name
static

Definition at line 70 of file iconv.c.

Referenced by tds_iconv_init(), and tds_set_iconv_name().

Modified on Fri Sep 20 14:56:57 2024 by modify_doxy.py rev. 669887