MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CharsetMap Class Reference

#include <CharsetMap.hpp>

Public Types

enum  RecodeStatus { RECODE_OK, RECODE_BAD_CHARSET, RECODE_BAD_SRC, RECODE_BUFF_TOO_SMALL }

Public Member Functions

const char * getName (int cs_number) const
const char * getMysqlName (int cs_number) const
int getCharsetNumber (const char *mysql_name) const
int getUTF8CharsetNumber () const
int getUTF16CharsetNumber () const
const bool * isMultibyte (int cs_number) const
RecodeStatus recode (int32_t *lengths, int cs_from, int cs_to, const void *src, void *dest) const

Static Public Member Functions

static void init ()
static void unload ()

Detailed Description

Handles encoding issues for character data while keeping MySQL's CHARSET_INFO structure hidden.

Definition at line 39 of file CharsetMap.hpp.

Member Enumeration Documentation

The return status of a buffer recode operation.

Definition at line 99 of file CharsetMap.hpp.

Member Function Documentation

int CharsetMap::getCharsetNumber ( const char *  mysql_name) const

Takes the mysql name (not the standardized name) and returns a character set number.

Definition at line 95 of file CharsetMap.cpp.

const char * CharsetMap::getMysqlName ( int  cs_number) const

Returns just the internal mysql name of the charset.

Definition at line 76 of file CharsetMap.cpp.

const char * CharsetMap::getName ( int  cs_number) const

Returns a standard character set name.

The cs_number argument in getName(), getMysqlName(), and recode() can be obtained from NdbDictionary::Column::getCharsetNumber().

getName() returns a name that in most cases will be a preferred name from http://www.iana.org/assignments/character-sets and will be recognized and usable by Java (e.g. java.nio, java.io, and java.lang). However it may return "binary" if a column is BLOB / BINARY / VARBINARY, or it may return the name of an obscure MySQL character set such as "keybcs2" or "dec8".

Definition at line 70 of file CharsetMap.cpp.

Here is the call graph for this function:

int CharsetMap::getUTF16CharsetNumber ( ) const

Convenience function for UTF-16.

Definition at line 89 of file CharsetMap.cpp.

int CharsetMap::getUTF8CharsetNumber ( ) const

Convenience function for UTF-8.

Definition at line 83 of file CharsetMap.cpp.

CharsetMap::init ( )
static

Initializes any global CharsetMap resources. Should be called exactly once before any other CharsetMap function from a single thread.

Definition at line 43 of file CharsetMap.cpp.

const bool * CharsetMap::isMultibyte ( int  cs_number) const

Returns true if this charset number refers to a multibyte charset; otherwise false.

Definition at line 100 of file CharsetMap.cpp.

CharsetMap::RecodeStatus CharsetMap::recode ( int32_t *  lengths,
int  cs_from,
int  cs_to,
const void *  src,
void *  dest 
) const

Recodes the content of a source buffer into destination buffer.

Takes five arguments: lengths is an array of two ints: first the source buffer length, then the destination buffer length. From and To are character set numbers. src and dest are buffers.

On return, lengths[0] is set to the number of bytes consumed from src and lengths[1] to the number of bytes written to dest.

The string in src will be recoded from charset cs_from to charset cs_to. If the conversion is successful we return RECODE_OK. Other return values are noted above.

Definition at line 108 of file CharsetMap.cpp.

void CharsetMap::unload ( )
static

Releases all global CharsetMap resources. Also not thread-safe

Definition at line 51 of file CharsetMap.cpp.


The documentation for this class was generated from the following files: