zoslib
z/OS C/C++ Library
Loading...
Searching...
No Matches
Classes | Macros | Typedefs | Functions | Variables
zos-char-util.cc File Reference
#include "zos-char-util.h"
#include "zos-base.h"
#include "zos-io.h"
#include <_Ccsid.h>
#include <ctest.h>
#include <fcntl.h>
#include <iconv.h>
#include <pthread.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unordered_map>

Classes

class  __csConverter
 
struct  IntHash
 
class  fdAttributeCache
 

Macros

#define _AE_BIMODAL   1
 

Typedefs

typedef unsigned long fd_attribute
 
typedef std::unordered_map< int, fd_attribute, IntHash >::const_iterator cursor_t
 

Functions

void * _convert_e2a (void *dst, const void *src, size_t size)
 
void * _convert_a2e (void *dst, const void *src, size_t size)
 
int __guess_ue (const void *src, size_t size, char *errmsg, size_t er_size)
 
void __set_ccsid_guess_buf_size (int nbytes)
 
int __guess_fd_ue (int fd, char *errmsg, size_t er_size, int is_new_fd)
 
int __guess_ae (const void *src, size_t size)
 
int conv_utf8_utf16 (char *out, size_t outsize, const char *in, size_t insize)
 
int conv_utf16_utf8 (char *out, size_t outsize, const char *in, size_t insize)
 
void __fd_close (int fd)
 
int __file_needs_conversion (int fd)
 
int __file_needs_conversion_init (const char *name, int fd)
 
void __set_autocvt_on_fd_stream (int fd, unsigned short ccsid, unsigned char txtflag, int on_untagged_only)
 

Variables

fdAttributeCache fdcache
 

Macro Definition Documentation

◆ _AE_BIMODAL

#define _AE_BIMODAL   1

Typedef Documentation

◆ cursor_t

typedef std::unordered_map<int,fd_attribute,IntHash>::const_iterator cursor_t

◆ fd_attribute

typedef unsigned long fd_attribute

Function Documentation

◆ __fd_close()

void __fd_close ( int  fd)

Unsets fd attributes

Parameters
[in]fdfile descriptor

◆ __file_needs_conversion()

int __file_needs_conversion ( int  fd)

Determines if file descriptor needs conversion from EBCDIC to ASCII. Call __file_needs_conversion_init first before calling this function.

Parameters
[in]fdfile descriptor
Returns
returns 1 if file needs conversion, 0 if not.

◆ __file_needs_conversion_init()

int __file_needs_conversion_init ( const char *  name,
int  fd 
)

Determines if file needs conversion from EBCDIC to ASCII.

Parameters
[in]namepath to file
[in]fdfile descriptor
Returns
returns 1 if file needs conversion, 0 if not.

◆ __guess_ae()

int __guess_ae ( const void *  src,
size_t  size 
)

Guess if string is ASCII or EBCDIC.

Parameters
[in]src- character string.
[in]size- number of bytes to analyze.
Returns
guessed CCSID.

◆ __guess_fd_ue()

int __guess_fd_ue ( int  fd,
char *  errmsg,
size_t  er_size,
int  is_new_fd 
)

Guess if string is UTF8 (ASCII) or EBCDIC based on the first CCSID_GUESS_BUF_SIZE_ENVAR of the file associated with the given fd. CCSID_GUESS_BUF_SIZE_ENVAR is default at 4KB.

Parameters
[in]fd- open file descriptor to guess.
Returns
guessed CCSID (819 for UTF8, 1047 for EBCDIC; otherwise 65535 for BINARY and, if not NULL, errmsg will contain details).

◆ __guess_ue()

int __guess_ue ( const void *  src,
size_t  size,
char *  errmsg,
size_t  er_size 
)

Guess if string is UTF8 (ASCII) or EBCDIC.

Parameters
[in]src- character string.
[in]size- number of bytes to analyze.
Returns
guessed CCSID (819 for UTF8, 1047 for EBCDIC; otherwise 65535 for BINARY and, if not NULL, errmsg will contain details).

◆ __set_autocvt_on_fd_stream()

void __set_autocvt_on_fd_stream ( int  fd,
unsigned short  ccsid,
unsigned char  txtflag,
int  on_untagged_only 
)

Sets file descriptor to auto convert.

Parameters
[in]fd- file descriptor.
[in]ccsid- CCSID to auto convert to.
[in]txtflag- Indicates if ccsid is text.
[in]on_untagged_only- applies only to untagged

◆ __set_ccsid_guess_buf_size()

void __set_ccsid_guess_buf_size ( int  nbytes)

◆ _convert_a2e()

void * _convert_a2e ( void *  dst,
const void *  src,
size_t  size 
)

Convert from ASCII to EBCDIC

Parameters
[out]dstDestination string (must be pre-allocated).
[in]srcSource string.
[in]sizeNumber of bytes to convert
Returns
returns destination string.

◆ _convert_e2a()

void * _convert_e2a ( void *  dst,
const void *  src,
size_t  size 
)

Convert from EBCDIC to ASCII.

Parameters
[out]dstDestination string (must be pre-allocated).
[in]srcSource string.
[in]sizeNumber of bytes to convert.
Returns
returns destination string.

◆ conv_utf16_utf8()

int conv_utf16_utf8 ( char *  out,
size_t  outsize,
const char *  in,
size_t  insize 
)

Convert string from UTF16 to UTF8.

◆ conv_utf8_utf16()

int conv_utf8_utf16 ( char *  out,
size_t  outsize,
const char *  in,
size_t  insize 
)

Convert string from UTF8 to UTF16

Variable Documentation

◆ fdcache