Functions | Variables

ut_iconv.cpp File Reference

#include <string.h>
#include <stdlib.h>
#include "ut_iconv.h"
#include "ut_assert.h"
#include "ut_debugmsg.h"
#include <glib.h>
#include "xap_EncodingManager.h"

Functions

static void s_internal_init ()
const char * ucs2Internal ()
const char * ucs4Internal ()
int UT_iconv_isValid (UT_iconv_t cd)
UT_iconv_t UT_iconv_open (const char *to, const char *from)
size_t UT_iconv (UT_iconv_t cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
int UT_iconv_close (UT_iconv_t cd)
void UT_iconv_reset (UT_iconv_t cd)
char * UT_convert (const char *str, UT_sint32 len, const char *from_codeset, const char *to_codeset, UT_uint32 *bytes_read_arg, UT_uint32 *bytes_written_arg)
char * UT_convert_cd (const char *str, UT_sint32 len, UT_iconv_t cd, UT_uint32 *bytes_read_arg, UT_uint32 *bytes_written_arg)

Variables

static const char * s_ucs2_internal = 0
static const char * s_ucs4_internal = 0
static const char * s_ucs2_list []
static const char * s_ucs4_list []

Function Documentation

static void s_internal_init (  )  [static]
const char* ucs2Internal (  ) 
Returns:
the internal iconv UCS-2 charset name

References s_internal_init().

const char* ucs4Internal (  ) 
Returns:
the internal iconv UCS-4 charset name

References s_internal_init().

Referenced by init_values(), and UT_Wctomb::setOutCharset().

char* UT_convert ( const char *  str,
UT_sint32  len,
const char *  from_codeset,
const char *  to_codeset,
UT_uint32 bytes_read_arg,
UT_uint32 bytes_written_arg 
)

Borrowed from GLib 2.0 and (heavily) modified

Parameters:
str Pointer to the input string.
len Length of the input string to convert.
from_codeset The "codeset" of the string pointed to by 'str'.
to_codeset The "codeset" we want for the output.
bytes_read optional, supply NULL if you don't want this.
bytes_written optional, supply NULL if you don't want this.
Returns:
Returns a freshly allocated output string, which is terminated by a zero byte. Note that if the output codeset's terminator is not a zero byte (e.g., UCS-2, where it is two zero bytes), you can get correct termination by including the input string's terminator in the length passed as 'len'. E.g., if 'str' is null-terminated US-ASCII "foo", given 'len' as 4.
Todo:
Check for out-of-memory allocations etc.

Referenced by IE_Imp_Hancom::_loadFile(), UT_Win32LocaleString::fromUCS4(), UT_Win32LocaleString::fromUTF8(), AP_UnixApp::pasteFromClipboard(), prepare_style_name(), UT_Win32LocaleString::ucs4_str(), UT_std_stringFromEncoding(), UT_UTF8String::UT_UTF8String(), UT_Win32LocaleString::utf8_str(), and utf8_to_ucs2().

char* UT_convert_cd ( const char *  str,
UT_sint32  len,
UT_iconv_t  cd,
UT_uint32 bytes_read_arg,
UT_uint32 bytes_written_arg 
)

This function is almost the same as the other UT_convert function, only that it takes an UT_iconv_t instead of a from and to codeset. This is useful if you need to do a conversion multiple times

Referenced by IE_Imp_StarOffice::_loadFile(), XAP_StringSet::getValue(), DocHdr::load(), and readByteString().

size_t UT_iconv ( UT_iconv_t  cd,
const char **  inbuf,
size_t *  inbytesleft,
char **  outbuf,
size_t *  outbytesleft 
)
int UT_iconv_close ( UT_iconv_t  cd  ) 
int UT_iconv_isValid ( UT_iconv_t  cd  ) 
UT_iconv_t UT_iconv_open ( const char *  to,
const char *  from 
)
void UT_iconv_reset ( UT_iconv_t  cd  ) 

Variable Documentation

const char* s_ucs2_internal = 0 [static]
const char* s_ucs2_list[] [static]
Initial value:
 {
    "UCS-2-INTERNAL",
    "UCS-2-LE",
    "UCS-2-BE",
    "UCS-2LE",
    "UCS-2BE",
    "UTF16-LE",
    "UTF16-BE",
    "UCS2",
    "UCS-2",
    "UTF-16",
    0
}
const char* s_ucs4_internal = 0 [static]
const char* s_ucs4_list[] [static]
Initial value:
 {
    "UCS-4-INTERNAL",
    "UCS-4-LE",
    "UCS-4-BE",
    "UCS-4LE",
    "UCS-4BE",
    "UTF-32LE",
    "UTF-32BE",
    "UCS4",
    "UCS-4",
    "UTF32",
    "UTF-32",
    0
}