ekg2  GIT master
Definicje | Funkcje
Dokumentacja pliku recode.h
#include "dynstuff.h"
Wykres zależności załączania dla recode.h:
Ten wykres pokazuje, które pliki bezpośrednio lub pośrednio załączają ten plik:

Idź do kodu źródłowego tego pliku.

Definicje

#define EKG_RECODE_CP   "CP-1250"
 
#define EKG_RECODE_ISO2   "ISO-8859-2"
 
#define EKG_RECODE_UTF8   "UTF-8"
 
#define recode_xfree(org, ret)   xfree((char *) ret);
 
#define ekg_recode_cp_inc()   ekg_recode_inc_ref(EKG_RECODE_CP)
 
#define ekg_recode_cp_dec()   ekg_recode_dec_ref(EKG_RECODE_CP)
 
#define ekg_locale_to_cp(buf)   ekg_recode_from_core(EKG_RECODE_CP, buf)
 
#define ekg_cp_to_core(buf)   ekg_recode_to_core(EKG_RECODE_CP, buf)
 
#define ekg_locale_to_cp_dup(buf)   ekg_recode_from_core_dup(EKG_RECODE_CP, buf)
 
#define ekg_cp_to_core_dup(buf)   ekg_recode_to_core_dup(EKG_RECODE_CP, buf)
 
#define ekg_locale_to_cp_use(buf)   ekg_recode_from_core_use(EKG_RECODE_CP, buf)
 
#define ekg_cp_to_core_use(buf)   ekg_recode_to_core_use(EKG_RECODE_CP, buf)
 
#define ekg_recode_iso2_inc()   ekg_recode_inc_ref(EKG_RECODE_ISO2)
 
#define ekg_recode_iso2_dec()   ekg_recode_dec_ref(EKG_RECODE_ISO2)
 
#define ekg_locale_to_iso2(buf)   ekg_recode_from_core(EKG_RECODE_ISO2, buf)
 
#define ekg_iso2_to_core(buf)   ekg_recode_to_core(EKG_RECODE_ISO2, buf)
 
#define ekg_locale_to_iso2_dup(buf)   ekg_recode_from_core_dup(EKG_RECODE_ISO2, buf)
 
#define ekg_iso2_to_core_dup(buf)   ekg_recode_to_core_dup(EKG_RECODE_ISO2, buf)
 
#define ekg_locale_to_iso2_use(buf)   ekg_recode_from_core_use(EKG_RECODE_ISO2, buf)
 
#define ekg_iso2_to_core_use(buf)   ekg_recode_to_core_use(EKG_RECODE_ISO2, buf)
 
#define ekg_recode_utf8_inc()   ekg_recode_inc_ref(EKG_RECODE_UTF8)
 
#define ekg_recode_utf8_dec()   ekg_recode_dec_ref(EKG_RECODE_UTF8)
 
#define ekg_locale_to_utf8(buf)   ekg_recode_from_core(EKG_RECODE_UTF8, buf)
 
#define ekg_utf8_to_core(buf)   ekg_recode_to_core(EKG_RECODE_UTF8, buf)
 
#define ekg_locale_to_utf8_dup(buf)   ekg_recode_from_core_dup(EKG_RECODE_UTF8, buf)
 
#define ekg_utf8_to_core_dup(buf)   ekg_recode_to_core_dup(EKG_RECODE_UTF8, buf)
 
#define ekg_locale_to_utf8_use(buf)   ekg_recode_from_core_use(EKG_RECODE_UTF8, buf)
 
#define ekg_utf8_to_core_use(buf)   ekg_recode_to_core_use(EKG_RECODE_UTF8, buf)
 

Funkcje

void * ekg_convert_string_init (const char *from, const char *to, void **rev)
 
void ekg_convert_string_destroy (void *ptr)
 
char * ekg_convert_string_p (const char *ps, void *ptr)
 
char * ekg_convert_string (const char *ps, const char *from, const char *to)
 
string_t ekg_convert_string_t_p (string_t s, void *ptr)
 
string_t ekg_convert_string_t (string_t s, const char *from, const char *to)
 
void changed_console_charset (const char *name)
 
int ekg_converters_display (int quiet)
 
void ekg_recode_inc_ref (const gchar *enc)
 
void ekg_recode_dec_ref (const gchar *enc)
 
char * ekg_recode_from_core (const gchar *enc, gchar *buf)
 
gchar * ekg_recode_to_core (const gchar *enc, char *buf)
 
char * ekg_recode_from_core_dup (const gchar *enc, const gchar *buf)
 
gchar * ekg_recode_to_core_dup (const gchar *enc, const char *buf)
 
const char * ekg_recode_from_core_use (const gchar *enc, const gchar *buf)
 
const gchar * ekg_recode_to_core_use (const gchar *enc, const char *buf)
 
gchar * ekg_recode_from (const gchar *enc, const char *str)
 
char * ekg_recode_to (const gchar *enc, const gchar *str)
 
gchar * ekg_recode_from_locale (const char *str)
 
char * ekg_recode_to_locale (const gchar *str)
 
gboolean ekg_recode_gstring_from (const gchar *enc, GString *s)
 
gboolean ekg_try_recode_gstring_from (const gchar *enc, GString *s)
 
gboolean ekg_recode_gstring_to (const gchar *enc, GString *s)
 
void ekg_fix_utf8 (gchar *buf)
 
fstring_tekg_recode_fstr_to_locale (const fstring_t *fstr)
 

Dokumentacja definicji

◆ ekg_cp_to_core

#define ekg_cp_to_core (   buf)    ekg_recode_to_core(EKG_RECODE_CP, buf)

◆ ekg_cp_to_core_dup

#define ekg_cp_to_core_dup (   buf)    ekg_recode_to_core_dup(EKG_RECODE_CP, buf)

◆ ekg_cp_to_core_use

#define ekg_cp_to_core_use (   buf)    ekg_recode_to_core_use(EKG_RECODE_CP, buf)

◆ ekg_iso2_to_core

#define ekg_iso2_to_core (   buf)    ekg_recode_to_core(EKG_RECODE_ISO2, buf)

◆ ekg_iso2_to_core_dup

#define ekg_iso2_to_core_dup (   buf)    ekg_recode_to_core_dup(EKG_RECODE_ISO2, buf)

◆ ekg_iso2_to_core_use

#define ekg_iso2_to_core_use (   buf)    ekg_recode_to_core_use(EKG_RECODE_ISO2, buf)

◆ ekg_locale_to_cp

#define ekg_locale_to_cp (   buf)    ekg_recode_from_core(EKG_RECODE_CP, buf)

◆ ekg_locale_to_cp_dup

#define ekg_locale_to_cp_dup (   buf)    ekg_recode_from_core_dup(EKG_RECODE_CP, buf)

◆ ekg_locale_to_cp_use

#define ekg_locale_to_cp_use (   buf)    ekg_recode_from_core_use(EKG_RECODE_CP, buf)

◆ ekg_locale_to_iso2

#define ekg_locale_to_iso2 (   buf)    ekg_recode_from_core(EKG_RECODE_ISO2, buf)

◆ ekg_locale_to_iso2_dup

#define ekg_locale_to_iso2_dup (   buf)    ekg_recode_from_core_dup(EKG_RECODE_ISO2, buf)

◆ ekg_locale_to_iso2_use

#define ekg_locale_to_iso2_use (   buf)    ekg_recode_from_core_use(EKG_RECODE_ISO2, buf)

◆ ekg_locale_to_utf8

#define ekg_locale_to_utf8 (   buf)    ekg_recode_from_core(EKG_RECODE_UTF8, buf)

◆ ekg_locale_to_utf8_dup

#define ekg_locale_to_utf8_dup (   buf)    ekg_recode_from_core_dup(EKG_RECODE_UTF8, buf)

◆ ekg_locale_to_utf8_use

#define ekg_locale_to_utf8_use (   buf)    ekg_recode_from_core_use(EKG_RECODE_UTF8, buf)

◆ EKG_RECODE_CP

#define EKG_RECODE_CP   "CP-1250"

◆ ekg_recode_cp_dec

#define ekg_recode_cp_dec ( )    ekg_recode_dec_ref(EKG_RECODE_CP)

◆ ekg_recode_cp_inc

#define ekg_recode_cp_inc ( )    ekg_recode_inc_ref(EKG_RECODE_CP)

◆ EKG_RECODE_ISO2

#define EKG_RECODE_ISO2   "ISO-8859-2"

◆ ekg_recode_iso2_dec

#define ekg_recode_iso2_dec ( )    ekg_recode_dec_ref(EKG_RECODE_ISO2)

◆ ekg_recode_iso2_inc

#define ekg_recode_iso2_inc ( )    ekg_recode_inc_ref(EKG_RECODE_ISO2)

◆ EKG_RECODE_UTF8

#define EKG_RECODE_UTF8   "UTF-8"

◆ ekg_recode_utf8_dec

#define ekg_recode_utf8_dec ( )    ekg_recode_dec_ref(EKG_RECODE_UTF8)

◆ ekg_recode_utf8_inc

#define ekg_recode_utf8_inc ( )    ekg_recode_inc_ref(EKG_RECODE_UTF8)

◆ ekg_utf8_to_core

#define ekg_utf8_to_core (   buf)    ekg_recode_to_core(EKG_RECODE_UTF8, buf)

◆ ekg_utf8_to_core_dup

#define ekg_utf8_to_core_dup (   buf)    ekg_recode_to_core_dup(EKG_RECODE_UTF8, buf)

◆ ekg_utf8_to_core_use

#define ekg_utf8_to_core_use (   buf)    ekg_recode_to_core_use(EKG_RECODE_UTF8, buf)

◆ recode_xfree

#define recode_xfree (   org,
  ret 
)    xfree((char *) ret);

Dokumentacja funkcji

◆ changed_console_charset()

void changed_console_charset ( const char *  name)

◆ ekg_convert_string()

char* ekg_convert_string ( const char *  ps,
const char *  from,
const char *  to 
)

ekg_convert_string()

Converts string to specified encoding, replacing invalid chars with question marks.

Nota
Deprecated, in favour of ekg_convert_string_p(). Should be used only on single conversions, where charset pair won't be used again.
Parametry
ps- string to be converted (it won't be freed).
from- input encoding (if NULL, console_charset will be assumed).
to- output encoding (if NULL, console_charset will be assumed).
Zwraca
Pointer to allocated result on success, NULL on failure or when both encodings are equal.
Zobacz również
ekg_convert_string_p() - more optimized version.

◆ ekg_convert_string_destroy()

void ekg_convert_string_destroy ( void *  ptr)

ekg_convert_string_destroy()

Frees internal data associated with given pointer, and uninitalizes iconv, if it's not needed anymore.

Nota
If 'rev' param was used with ekg_convert_string_init(), this functions must be called two times
  • with returned value, and with rev-associated one.
Parametry
ptr- pointer returned by ekg_convert_string_init().
Zobacz również
ekg_convert_string_init() - init charset conversion.
ekg_convert_string_p() - main charset conversion function.

◆ ekg_convert_string_init()

void* ekg_convert_string_init ( const char *  from,
const char *  to,
void **  rev 
)

ekg_convert_string_init()

Initialize string conversion thing for two given charsets.

Parametry
from- input encoding (will be duped; if NULL, console_charset will be assumed).
to- output encoding (will be duped; if NULL, console_charset will be assumed).
rev- pointer to assign reverse conversion into; if NULL, no reverse converter will be initialized.
Zwraca
Pointer that should be passed to other ekg_convert_string_*(), even if it's NULL.
Zobacz również
ekg_convert_string_destroy() - deinits charset conversion.
ekg_convert_string_p() - main charset conversion function.

◆ ekg_convert_string_p()

char* ekg_convert_string_p ( const char *  ps,
void *  ptr 
)

ekg_convert_string_p()

Converts string to specified encoding, using pointer returned by ekg_convert_string_init(). Invalid characters in input will be replaced with question marks.

Parametry
ps- string to be converted (won't be freed).
ptr- pointer returned by ekg_convert_string_init().
Zwraca
Pointer to allocated result or NULL, if some failure has occured or no conversion is needed (i.e. resulting string would be same as input).
Zobacz również
ekg_convert_string_init() - init charset conversion.

◆ ekg_convert_string_t()

string_t ekg_convert_string_t ( string_t  s,
const char *  from,
const char *  to 
)

◆ ekg_convert_string_t_p()

string_t ekg_convert_string_t_p ( string_t  s,
void *  ptr 
)

◆ ekg_converters_display()

int ekg_converters_display ( int  quiet)

◆ ekg_fix_utf8()

void ekg_fix_utf8 ( gchar *  buf)

ekg_fix_utf8()

Ensure correct utf8 in buffer, replacing incorrect sequences.

Parametry
buf- writable, null-terminated, utf8 string.
Nota
Currently, this function replaces incorrect bytes with ASCII SUB (0x1a). This may change in future.

◆ ekg_recode_dec_ref()

void ekg_recode_dec_ref ( const gchar *  enc)

◆ ekg_recode_from()

gchar* ekg_recode_from ( const gchar *  enc,
const char *  str 
)

ekg_recode_from()

Convert complete string str from given encoding to ekg2 internal encoding (utf8). If the conversion fails, fallback to duplicating and utf8-cleaning str.

Parametry
enc- source encoding (e.g. "iso-8859-2").
str- string to recode [may be NULL].
Zwraca
A newly-allocated string which is guaranteed to be correct utf8 and needs to be freed using g_free(), or NULL if !str.

◆ ekg_recode_from_core()

char* ekg_recode_from_core ( const gchar *  enc,
gchar *  buf 
)

◆ ekg_recode_from_core_dup()

char* ekg_recode_from_core_dup ( const gchar *  enc,
const gchar *  buf 
)

◆ ekg_recode_from_core_use()

const char* ekg_recode_from_core_use ( const gchar *  enc,
const gchar *  buf 
)

◆ ekg_recode_from_locale()

gchar* ekg_recode_from_locale ( const char *  str)

ekg_recode_from_locale()

Convert complete string str from locale to ekg2 internal encoding (utf8). If the conversion fails, fallback to duplicating and utf8-cleaning the string.

Parametry
str- string to recode. May be NULL.
Zwraca
A newly-allocated string which must be freed using g_free(), or NULL if !str.

◆ ekg_recode_fstr_to_locale()

fstring_t* ekg_recode_fstr_to_locale ( const fstring_t fstr)

ekg_recode_fstr_to_locale()

Recode fstring_t from ekg2 internal encoding (utf8) to locale, adjusting attributes as necessary. Set attributes based on special unicode character properties (e.g. FSTR_LINEBREAK).

Parametry
fstr- input fstring_t.
Zwraca
Newly-allocated fstring_t, which needs to be freed using fstring_free().

◆ ekg_recode_gstring_from()

gboolean ekg_recode_gstring_from ( const gchar *  enc,
GString *  s 
)

ekg_recode_gstring_from()

Convert complete GString in-place from given encoding to ekg2 internal encoding (utf8). If the conversion fails, fallback to utf8-cleaning the string.

Parametry
enc- source encoding.
s- GString to recode and to write the result into. After the call to this function, it is guaranteed to contain correct utf8.
Zwraca
TRUE if conversion succeeded, FALSE otherwise.

◆ ekg_recode_gstring_to()

gboolean ekg_recode_gstring_to ( const gchar *  enc,
GString *  s 
)

ekg_recode_gstring_to()

Convert complete GString in-place from ekg2 internal encoding (utf8) to given encoding. If the conversion fails, leave string unchanged.

Parametry
enc- target encoding.
s- GString to recode and to write the result into if the conversion succeeds.
Zwraca
TRUE if conversion succeeded, FALSE otherwise.

◆ ekg_recode_inc_ref()

void ekg_recode_inc_ref ( const gchar *  enc)

◆ ekg_recode_to()

char* ekg_recode_to ( const gchar *  enc,
const gchar *  str 
)

ekg_recode_to()

Convert complete string str from ekg2 internal encoding (utf8) to given encoding. If the conversion fails, fallback to duplicating the string.

Parametry
enc- target encoding (e.g. "iso-8859-2").
str- string to recode [may be NULL].
Zwraca
A newly-allocated string which must be freed using g_free(), or NULL if !str.

◆ ekg_recode_to_core()

gchar* ekg_recode_to_core ( const gchar *  enc,
char *  buf 
)

◆ ekg_recode_to_core_dup()

gchar* ekg_recode_to_core_dup ( const gchar *  enc,
const char *  buf 
)

◆ ekg_recode_to_core_use()

const gchar* ekg_recode_to_core_use ( const gchar *  enc,
const char *  buf 
)

◆ ekg_recode_to_locale()

char* ekg_recode_to_locale ( const gchar *  str)

ekg_recode_to_locale()

Convert complete string str from ekg2 internal encoding (utf8) to locale. If the conversion fails, fallback to duplicating the string.

Parametry
str- string to recode. May be NULL.
Zwraca
A newly-allocated string which must be freed using g_free(), or NULL if !str.

◆ ekg_try_recode_gstring_from()

gboolean ekg_try_recode_gstring_from ( const gchar *  enc,
GString *  s 
)

ekg_try_recode_gstring_from()

Convert complete GString in-place from given encoding to ekg2 internal encoding (utf8). If the conversion fails, leave string unchanged.

Parametry
enc- source encoding.
s- GString to recode and to write the result into if the conversion succeeds.
Zwraca
TRUE if conversion succeeded, FALSE otherwise.