2007-08-25 00:14:26 -04:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
encoding.h -
|
|
|
|
|
|
|
|
$Author: matz $
|
|
|
|
created at: Thu May 24 11:49:41 JST 2007
|
|
|
|
|
|
|
|
Copyright (C) 2007 Yukihiro Matsumoto
|
|
|
|
|
|
|
|
**********************************************************************/
|
|
|
|
|
|
|
|
#ifndef RUBY_ENCODING_H
|
|
|
|
#define RUBY_ENCODING_H 1
|
|
|
|
|
2008-06-09 22:24:45 -04:00
|
|
|
#include <stdarg.h>
|
2007-08-25 00:14:26 -04:00
|
|
|
#include "ruby/oniguruma.h"
|
|
|
|
|
2007-12-21 06:00:04 -05:00
|
|
|
#define ENCODING_INLINE_MAX 1023
|
|
|
|
#define ENCODING_SHIFT (FL_USHIFT+10)
|
|
|
|
#define ENCODING_MASK (ENCODING_INLINE_MAX<<ENCODING_SHIFT)
|
2008-01-06 21:49:01 -05:00
|
|
|
|
|
|
|
#define ENCODING_SET_INLINED(obj,i) do {\
|
2007-08-25 00:14:26 -04:00
|
|
|
RBASIC(obj)->flags &= ~ENCODING_MASK;\
|
2008-01-06 21:49:01 -05:00
|
|
|
RBASIC(obj)->flags |= (i) << ENCODING_SHIFT;\
|
|
|
|
} while (0)
|
|
|
|
#define ENCODING_SET(obj,i) do {\
|
|
|
|
VALUE rb_encoding_set_obj = (obj); \
|
|
|
|
int encoding_set_enc_index = (i); \
|
|
|
|
if (encoding_set_enc_index < ENCODING_INLINE_MAX) \
|
|
|
|
ENCODING_SET_INLINED(rb_encoding_set_obj, encoding_set_enc_index); \
|
|
|
|
else \
|
2008-05-19 04:25:03 -04:00
|
|
|
rb_enc_set_index(rb_encoding_set_obj, encoding_set_enc_index); \
|
2007-08-25 00:14:26 -04:00
|
|
|
} while (0)
|
2008-01-06 21:49:01 -05:00
|
|
|
|
|
|
|
#define ENCODING_GET_INLINED(obj) ((RBASIC(obj)->flags & ENCODING_MASK)>>ENCODING_SHIFT)
|
|
|
|
#define ENCODING_GET(obj) \
|
|
|
|
(ENCODING_GET_INLINED(obj) != ENCODING_INLINE_MAX ? \
|
|
|
|
ENCODING_GET_INLINED(obj) : \
|
2008-05-19 04:25:03 -04:00
|
|
|
rb_enc_get_index(obj))
|
2008-01-06 21:49:01 -05:00
|
|
|
|
|
|
|
#define ENCODING_IS_ASCII8BIT(obj) (ENCODING_GET_INLINED(obj) == 0)
|
2007-08-25 00:14:26 -04:00
|
|
|
|
2008-01-16 00:55:22 -05:00
|
|
|
#define ENCODING_MAXNAMELEN 42
|
|
|
|
|
2007-12-21 06:00:04 -05:00
|
|
|
#define ENC_CODERANGE_MASK (FL_USER8|FL_USER9)
|
2007-09-26 15:46:58 -04:00
|
|
|
#define ENC_CODERANGE_UNKNOWN 0
|
2007-12-21 06:00:04 -05:00
|
|
|
#define ENC_CODERANGE_7BIT FL_USER8
|
|
|
|
#define ENC_CODERANGE_VALID FL_USER9
|
|
|
|
#define ENC_CODERANGE_BROKEN (FL_USER8|FL_USER9)
|
2007-09-26 15:46:58 -04:00
|
|
|
#define ENC_CODERANGE(obj) (RBASIC(obj)->flags & ENC_CODERANGE_MASK)
|
2007-11-26 21:21:17 -05:00
|
|
|
#define ENC_CODERANGE_ASCIIONLY(obj) (ENC_CODERANGE(obj) == ENC_CODERANGE_7BIT)
|
2007-09-30 04:13:28 -04:00
|
|
|
#define ENC_CODERANGE_SET(obj,cr) (RBASIC(obj)->flags = \
|
|
|
|
(RBASIC(obj)->flags & ~ENC_CODERANGE_MASK) | (cr))
|
2007-09-26 15:46:58 -04:00
|
|
|
#define ENC_CODERANGE_CLEAR(obj) ENC_CODERANGE_SET(obj,0)
|
2008-02-17 08:01:52 -05:00
|
|
|
|
2008-09-09 07:59:40 -04:00
|
|
|
/* assumed ASCII compatibility */
|
2008-02-17 08:01:52 -05:00
|
|
|
#define ENC_CODERANGE_AND(a, b) \
|
|
|
|
(a == ENC_CODERANGE_7BIT ? b : \
|
|
|
|
a == ENC_CODERANGE_VALID ? (b == ENC_CODERANGE_7BIT ? ENC_CODERANGE_VALID : b) : \
|
|
|
|
ENC_CODERANGE_UNKNOWN)
|
2007-09-26 15:46:58 -04:00
|
|
|
|
2008-01-06 21:49:01 -05:00
|
|
|
#define ENCODING_CODERANGE_SET(obj, encindex, cr) \
|
|
|
|
do { \
|
|
|
|
VALUE rb_encoding_coderange_obj = (obj); \
|
|
|
|
ENCODING_SET(rb_encoding_coderange_obj, (encindex)); \
|
|
|
|
ENC_CODERANGE_SET(rb_encoding_coderange_obj, (cr)); \
|
|
|
|
} while (0)
|
2007-09-26 15:46:58 -04:00
|
|
|
|
2007-08-25 00:14:26 -04:00
|
|
|
typedef OnigEncodingType rb_encoding;
|
|
|
|
|
2007-12-10 07:47:55 -05:00
|
|
|
int rb_enc_replicate(const char *, rb_encoding *);
|
2007-12-21 06:00:04 -05:00
|
|
|
int rb_define_dummy_encoding(const char *);
|
2008-07-04 07:44:05 -04:00
|
|
|
#define rb_enc_to_index(enc) ((enc) ? ENC_TO_ENCINDEX(enc) : 0)
|
2007-09-26 05:39:08 -04:00
|
|
|
int rb_enc_get_index(VALUE obj);
|
2008-05-19 04:25:03 -04:00
|
|
|
void rb_enc_set_index(VALUE obj, int encindex);
|
2007-09-28 15:27:10 -04:00
|
|
|
int rb_enc_find_index(const char *name);
|
2007-10-13 12:32:40 -04:00
|
|
|
int rb_to_encoding_index(VALUE);
|
|
|
|
rb_encoding* rb_to_encoding(VALUE);
|
2007-08-25 00:14:26 -04:00
|
|
|
rb_encoding* rb_enc_get(VALUE);
|
2007-10-21 21:57:08 -04:00
|
|
|
rb_encoding* rb_enc_compatible(VALUE,VALUE);
|
2007-08-25 00:14:26 -04:00
|
|
|
rb_encoding* rb_enc_check(VALUE,VALUE);
|
2008-05-20 18:26:14 -04:00
|
|
|
VALUE rb_enc_associate_index(VALUE, int);
|
|
|
|
VALUE rb_enc_associate(VALUE, rb_encoding*);
|
2007-12-28 09:55:43 -05:00
|
|
|
void rb_enc_copy(VALUE dst, VALUE src);
|
2007-08-25 00:14:26 -04:00
|
|
|
|
2008-01-04 11:30:33 -05:00
|
|
|
VALUE rb_enc_str_new(const char*, long, rb_encoding*);
|
|
|
|
VALUE rb_enc_reg_new(const char*, long, rb_encoding*, int);
|
2007-12-30 16:08:36 -05:00
|
|
|
PRINTF_ARGS(VALUE rb_enc_sprintf(rb_encoding *, const char*, ...), 2, 3);
|
|
|
|
VALUE rb_enc_vsprintf(rb_encoding *, const char*, va_list);
|
2007-08-25 00:14:26 -04:00
|
|
|
long rb_enc_strlen(const char*, const char*, rb_encoding*);
|
|
|
|
char* rb_enc_nth(const char*, const char*, int, rb_encoding*);
|
2007-10-04 02:57:19 -04:00
|
|
|
VALUE rb_obj_encoding(VALUE);
|
2008-01-06 04:25:09 -05:00
|
|
|
VALUE rb_enc_str_buf_cat(VALUE str, const char *ptr, long len, rb_encoding *enc);
|
2007-08-25 00:14:26 -04:00
|
|
|
|
2008-10-20 04:05:44 -04:00
|
|
|
VALUE rb_external_str_new_with_enc(const char *ptr, long len, rb_encoding *);
|
|
|
|
VALUE rb_str_export_to_enc(VALUE, rb_encoding *);
|
2008-10-21 05:18:34 -04:00
|
|
|
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to);
|
2008-10-18 06:36:20 -04:00
|
|
|
|
2007-08-25 00:14:26 -04:00
|
|
|
/* index -> rb_encoding */
|
|
|
|
rb_encoding* rb_enc_from_index(int idx);
|
|
|
|
|
|
|
|
/* name -> rb_encoding */
|
|
|
|
rb_encoding * rb_enc_find(const char *name);
|
|
|
|
|
2008-09-12 07:31:28 -04:00
|
|
|
/* rb_encoding * -> name */
|
2007-08-25 00:14:26 -04:00
|
|
|
#define rb_enc_name(enc) (enc)->name
|
|
|
|
|
2008-09-12 07:31:28 -04:00
|
|
|
/* rb_encoding * -> minlen/maxlen */
|
2007-08-25 00:14:26 -04:00
|
|
|
#define rb_enc_mbminlen(enc) (enc)->min_enc_len
|
|
|
|
#define rb_enc_mbmaxlen(enc) (enc)->max_enc_len
|
|
|
|
|
2007-12-23 10:19:23 -05:00
|
|
|
/* -> mbclen (no error notification: 0 < ret <= e-p, no exception) */
|
2007-12-23 09:06:00 -05:00
|
|
|
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc);
|
2007-08-27 09:48:09 -04:00
|
|
|
|
2007-12-10 22:08:50 -05:00
|
|
|
/* -> chlen, invalid or needmore */
|
|
|
|
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc);
|
2008-01-27 09:27:07 -05:00
|
|
|
#define MBCLEN_CHARFOUND_P(ret) ONIGENC_MBCLEN_CHARFOUND_P(ret)
|
|
|
|
#define MBCLEN_CHARFOUND_LEN(ret) ONIGENC_MBCLEN_CHARFOUND_LEN(ret)
|
|
|
|
#define MBCLEN_INVALID_P(ret) ONIGENC_MBCLEN_INVALID_P(ret)
|
|
|
|
#define MBCLEN_NEEDMORE_P(ret) ONIGENC_MBCLEN_NEEDMORE_P(ret)
|
|
|
|
#define MBCLEN_NEEDMORE_LEN(ret) ONIGENC_MBCLEN_NEEDMORE_LEN(ret)
|
2007-12-06 04:28:26 -05:00
|
|
|
|
2007-12-10 22:08:50 -05:00
|
|
|
/* -> 0x00..0x7f, -1 */
|
2007-12-11 02:39:16 -05:00
|
|
|
int rb_enc_ascget(const char *p, const char *e, int *len, rb_encoding *enc);
|
2007-12-07 21:50:43 -05:00
|
|
|
|
2007-12-23 10:19:23 -05:00
|
|
|
/* -> code or raise exception */
|
2008-09-11 06:34:59 -04:00
|
|
|
unsigned int rb_enc_codepoint(const char *p, const char *e, rb_encoding *enc);
|
2007-12-25 05:01:06 -05:00
|
|
|
#define rb_enc_mbc_to_codepoint(p, e, enc) ONIGENC_MBC_TO_CODE(enc,(UChar*)(p),(UChar*)(e))
|
2007-12-23 10:19:23 -05:00
|
|
|
|
2007-12-27 01:27:39 -05:00
|
|
|
/* -> codelen>0 or raise exception */
|
2008-09-18 08:53:25 -04:00
|
|
|
int rb_enc_codelen(int code, rb_encoding *enc);
|
2007-08-25 00:14:26 -04:00
|
|
|
|
2008-09-18 08:53:25 -04:00
|
|
|
/* code,ptr,encoding -> write buf */
|
|
|
|
#define rb_enc_mbcput(c,buf,enc) ONIGENC_CODE_TO_MBC(enc,c,(UChar*)(buf))
|
2007-08-25 00:14:26 -04:00
|
|
|
|
2008-09-13 14:22:04 -04:00
|
|
|
/* start, ptr, end, encoding -> prev_char */
|
|
|
|
#define rb_enc_prev_char(s,p,e,enc) (char *)onigenc_get_prev_char_head(enc,(UChar*)(s),(UChar*)(p),(UChar*)(e))
|
|
|
|
/* start, ptr, end, encoding -> next_char */
|
2008-09-13 15:23:52 -04:00
|
|
|
#define rb_enc_left_char_head(s,p,e,enc) (char *)onigenc_get_left_adjust_char_head(enc,(UChar*)(s),(UChar*)(p),(UChar*)(e))
|
2008-09-13 12:40:31 -04:00
|
|
|
#define rb_enc_right_char_head(s,p,e,enc) (char *)onigenc_get_right_adjust_char_head(enc,(UChar*)(s),(UChar*)(p),(UChar*)(e))
|
2007-08-25 00:14:26 -04:00
|
|
|
|
2008-01-21 14:47:26 -05:00
|
|
|
/* ptr, ptr, encoding -> newline_or_not */
|
2008-01-24 04:19:44 -05:00
|
|
|
#define rb_enc_is_newline(p,end,enc) ONIGENC_IS_MBC_NEWLINE(enc,(UChar*)(p),(UChar*)(end))
|
2008-01-21 14:47:26 -05:00
|
|
|
|
2007-09-28 15:27:10 -04:00
|
|
|
#define rb_enc_isctype(c,t,enc) ONIGENC_IS_CODE_CTYPE(enc,c,t)
|
2007-08-25 00:14:26 -04:00
|
|
|
#define rb_enc_isascii(c,enc) ONIGENC_IS_CODE_ASCII(c)
|
|
|
|
#define rb_enc_isalpha(c,enc) ONIGENC_IS_CODE_ALPHA(enc,c)
|
|
|
|
#define rb_enc_islower(c,enc) ONIGENC_IS_CODE_LOWER(enc,c)
|
|
|
|
#define rb_enc_isupper(c,enc) ONIGENC_IS_CODE_UPPER(enc,c)
|
2008-08-14 04:57:07 -04:00
|
|
|
#define rb_enc_ispunct(c,enc) ONIGENC_IS_CODE_PUNCT(enc,c)
|
2007-08-25 00:14:26 -04:00
|
|
|
#define rb_enc_isalnum(c,enc) ONIGENC_IS_CODE_ALNUM(enc,c)
|
|
|
|
#define rb_enc_isprint(c,enc) ONIGENC_IS_CODE_PRINT(enc,c)
|
|
|
|
#define rb_enc_isspace(c,enc) ONIGENC_IS_CODE_SPACE(enc,c)
|
|
|
|
#define rb_enc_isdigit(c,enc) ONIGENC_IS_CODE_DIGIT(enc,c)
|
|
|
|
|
2008-05-19 04:25:03 -04:00
|
|
|
#define rb_enc_asciicompat(enc) (rb_enc_mbminlen(enc)==1 && !rb_enc_dummy_p(enc))
|
2007-09-26 05:39:08 -04:00
|
|
|
|
2007-12-25 05:01:06 -05:00
|
|
|
int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc);
|
2007-08-25 00:14:26 -04:00
|
|
|
int rb_enc_toupper(int c, rb_encoding *enc);
|
|
|
|
int rb_enc_tolower(int c, rb_encoding *enc);
|
|
|
|
ID rb_intern3(const char*, long, rb_encoding*);
|
2007-12-25 05:01:06 -05:00
|
|
|
ID rb_interned_id_p(const char *, long, rb_encoding *);
|
2007-09-26 05:39:08 -04:00
|
|
|
int rb_enc_symname_p(const char*, rb_encoding*);
|
2007-09-26 15:46:58 -04:00
|
|
|
int rb_enc_str_coderange(VALUE);
|
2008-02-27 21:13:51 -05:00
|
|
|
long rb_str_coderange_scan_restartable(const char*, const char*, rb_encoding*, int*);
|
2007-11-25 08:25:34 -05:00
|
|
|
int rb_enc_str_asciionly_p(VALUE);
|
|
|
|
#define rb_enc_str_asciicompat_p(str) rb_enc_asciicompat(rb_enc_get(str))
|
2007-10-16 16:07:20 -04:00
|
|
|
VALUE rb_enc_from_encoding(rb_encoding *enc);
|
2007-12-22 18:47:18 -05:00
|
|
|
rb_encoding *rb_ascii8bit_encoding(void);
|
2007-12-21 01:59:48 -05:00
|
|
|
rb_encoding *rb_utf8_encoding(void);
|
2008-01-23 11:03:29 -05:00
|
|
|
rb_encoding *rb_usascii_encoding(void);
|
2007-12-28 05:12:13 -05:00
|
|
|
rb_encoding *rb_locale_encoding(void);
|
2008-06-16 17:28:03 -04:00
|
|
|
rb_encoding *rb_filesystem_encoding(void);
|
2007-12-01 09:05:53 -05:00
|
|
|
rb_encoding *rb_default_external_encoding(void);
|
2008-10-07 13:39:44 -04:00
|
|
|
rb_encoding *rb_default_internal_encoding(void);
|
2008-05-20 15:21:26 -04:00
|
|
|
int rb_ascii8bit_encindex(void);
|
2008-06-29 13:33:01 -04:00
|
|
|
int rb_utf8_encindex(void);
|
|
|
|
int rb_usascii_encindex(void);
|
2007-12-01 09:05:53 -05:00
|
|
|
VALUE rb_enc_default_external(void);
|
2008-10-07 13:39:44 -04:00
|
|
|
VALUE rb_enc_default_internal(void);
|
2007-12-01 09:05:53 -05:00
|
|
|
void rb_enc_set_default_external(VALUE encoding);
|
2008-10-07 13:39:44 -04:00
|
|
|
void rb_enc_set_default_internal(VALUE encoding);
|
2007-12-20 21:52:23 -05:00
|
|
|
VALUE rb_locale_charmap(VALUE klass);
|
2008-03-17 15:04:29 -04:00
|
|
|
long rb_memsearch(const void*,long,const void*,long,rb_encoding*);
|
2007-08-25 00:14:26 -04:00
|
|
|
|
2008-05-19 04:25:03 -04:00
|
|
|
RUBY_EXTERN VALUE rb_cEncoding;
|
2008-07-04 07:44:05 -04:00
|
|
|
#define enc_initialized_p(enc) ((enc)->ruby_encoding_index != ENC_UNINITIALIZED)
|
|
|
|
#define ENC_DUMMY_FLAG (1<<24)
|
|
|
|
#define ENC_INDEX_MASK (~(~0U<<24))
|
2008-05-19 04:25:03 -04:00
|
|
|
|
2008-07-04 07:44:05 -04:00
|
|
|
#define ENC_TO_ENCINDEX(enc) ((enc)->ruby_encoding_index & ENC_INDEX_MASK)
|
|
|
|
#define ENC_FROM_ENCINDEX(idx) (RARRAY_PTR(rb_encoding_list)[idx])
|
|
|
|
#define ENC_FROM_ENCODING(enc) ENC_FROM_ENCINDEX(ENC_TO_ENCINDEX(enc))
|
2008-05-19 04:25:03 -04:00
|
|
|
|
2008-07-04 07:44:05 -04:00
|
|
|
#define ENC_DUMMY_P(enc) ((enc)->ruby_encoding_index & ENC_DUMMY_FLAG)
|
|
|
|
#define ENC_SET_DUMMY(enc) ((enc)->ruby_encoding_index |= ENC_DUMMY_FLAG)
|
2008-05-19 04:25:03 -04:00
|
|
|
|
|
|
|
static inline int
|
|
|
|
rb_enc_dummy_p(rb_encoding *enc)
|
|
|
|
{
|
2008-07-04 07:44:05 -04:00
|
|
|
return ENC_DUMMY_P(enc) != 0;
|
2008-05-19 04:25:03 -04:00
|
|
|
}
|
|
|
|
|
2008-08-14 10:28:10 -04:00
|
|
|
/* econv stuff */
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
econv_invalid_byte_sequence,
|
|
|
|
econv_undefined_conversion,
|
|
|
|
econv_destination_buffer_full,
|
|
|
|
econv_source_buffer_empty,
|
|
|
|
econv_finished,
|
2008-09-09 12:27:02 -04:00
|
|
|
econv_after_output,
|
2008-09-21 22:47:05 -04:00
|
|
|
econv_incomplete_input
|
2008-08-14 10:28:10 -04:00
|
|
|
} rb_econv_result_t;
|
|
|
|
|
2008-08-26 11:01:11 -04:00
|
|
|
typedef struct rb_econv_t rb_econv_t;
|
2008-08-14 10:28:10 -04:00
|
|
|
|
2008-09-26 06:35:00 -04:00
|
|
|
VALUE rb_str_encode(VALUE str, VALUE to, int ecflags, VALUE ecopts);
|
|
|
|
int rb_econv_has_convpath_p(const char* from_encoding, const char* to_encoding);
|
2008-08-24 04:39:09 -04:00
|
|
|
|
2008-09-03 14:18:10 -04:00
|
|
|
int rb_econv_prepare_opts(VALUE opthash, VALUE *ecopts);
|
2008-08-24 03:20:21 -04:00
|
|
|
|
2008-09-03 11:11:46 -04:00
|
|
|
rb_econv_t *rb_econv_open(const char *source_encoding, const char *destination_encoding, int ecflags);
|
2008-09-03 14:18:10 -04:00
|
|
|
rb_econv_t *rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts);
|
|
|
|
|
2008-08-14 10:28:10 -04:00
|
|
|
rb_econv_result_t rb_econv_convert(rb_econv_t *ec,
|
2008-08-14 11:56:39 -04:00
|
|
|
const unsigned char **source_buffer_ptr, const unsigned char *source_buffer_end,
|
|
|
|
unsigned char **destination_buffer_ptr, unsigned char *destination_buffer_end,
|
2008-08-14 10:28:10 -04:00
|
|
|
int flags);
|
2008-08-17 00:25:56 -04:00
|
|
|
void rb_econv_close(rb_econv_t *ec);
|
2008-08-15 07:02:07 -04:00
|
|
|
|
2008-09-03 12:34:11 -04:00
|
|
|
/* result: 0:success -1:failure */
|
2008-09-07 13:08:38 -04:00
|
|
|
int rb_econv_set_replacement(rb_econv_t *ec, const unsigned char *str, size_t len, const char *encname);
|
2008-09-03 12:34:11 -04:00
|
|
|
|
2008-09-08 13:23:37 -04:00
|
|
|
/* result: 0:success -1:failure */
|
|
|
|
int rb_econv_decorate_at_first(rb_econv_t *ec, const char *decorator_name);
|
|
|
|
int rb_econv_decorate_at_last(rb_econv_t *ec, const char *decorator_name);
|
|
|
|
|
2008-09-03 11:11:46 -04:00
|
|
|
VALUE rb_econv_open_exc(const char *senc, const char *denc, int ecflags);
|
2008-08-23 22:42:37 -04:00
|
|
|
|
2008-08-16 01:32:42 -04:00
|
|
|
/* result: 0:success -1:failure */
|
|
|
|
int rb_econv_insert_output(rb_econv_t *ec,
|
|
|
|
const unsigned char *str, size_t len, const char *str_encoding);
|
|
|
|
|
|
|
|
/* encoding that rb_econv_insert_output doesn't need conversion */
|
|
|
|
const char *rb_econv_encoding_to_insert_output(rb_econv_t *ec);
|
2008-08-15 07:02:07 -04:00
|
|
|
|
2008-08-16 11:04:39 -04:00
|
|
|
/* raise an error if the last rb_econv_convert is error */
|
|
|
|
void rb_econv_check_error(rb_econv_t *ec);
|
|
|
|
|
2008-08-17 00:25:56 -04:00
|
|
|
int rb_econv_putbackable(rb_econv_t *ec);
|
|
|
|
void rb_econv_putback(rb_econv_t *ec, unsigned char *p, int n);
|
2008-08-14 10:28:10 -04:00
|
|
|
|
2008-09-08 10:33:17 -04:00
|
|
|
/* returns the corresponding ASCII compatible encoding for encname,
|
|
|
|
* or NULL if encname is not ASCII incompatible encoding. */
|
|
|
|
const char *rb_econv_asciicompat_encoding(const char *encname);
|
2008-08-18 08:06:42 -04:00
|
|
|
|
2008-08-23 23:22:43 -04:00
|
|
|
VALUE rb_econv_str_convert(rb_econv_t *ec, VALUE src, int flags);
|
|
|
|
VALUE rb_econv_substr_convert(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, int flags);
|
|
|
|
VALUE rb_econv_str_append(rb_econv_t *ec, VALUE src, VALUE dst, int flags);
|
|
|
|
VALUE rb_econv_substr_append(rb_econv_t *ec, VALUE src, long byteoff, long bytesize, VALUE dst, int flags);
|
2008-08-18 08:06:42 -04:00
|
|
|
|
2008-08-22 12:44:00 -04:00
|
|
|
void rb_econv_binmode(rb_econv_t *ec);
|
|
|
|
|
2008-08-14 10:48:41 -04:00
|
|
|
/* flags for rb_econv_open */
|
2008-08-23 02:02:58 -04:00
|
|
|
|
2008-09-06 11:39:00 -04:00
|
|
|
#define ECONV_ERROR_HANDLER_MASK 0x000000ff
|
|
|
|
|
|
|
|
#define ECONV_INVALID_MASK 0x0000000f
|
|
|
|
#define ECONV_INVALID_REPLACE 0x00000002
|
|
|
|
|
|
|
|
#define ECONV_UNDEF_MASK 0x000000f0
|
|
|
|
#define ECONV_UNDEF_REPLACE 0x00000020
|
|
|
|
#define ECONV_UNDEF_HEX_CHARREF 0x00000030
|
2008-08-23 02:02:58 -04:00
|
|
|
|
2008-09-09 08:22:43 -04:00
|
|
|
#define ECONV_DECORATOR_MASK 0x0000ff00
|
|
|
|
|
|
|
|
#define ECONV_UNIVERSAL_NEWLINE_DECORATOR 0x00000100
|
|
|
|
#define ECONV_CRLF_NEWLINE_DECORATOR 0x00001000
|
|
|
|
#define ECONV_CR_NEWLINE_DECORATOR 0x00002000
|
|
|
|
#define ECONV_XML_TEXT_DECORATOR 0x00004000
|
|
|
|
#define ECONV_XML_ATTR_CONTENT_DECORATOR 0x00008000
|
|
|
|
|
|
|
|
#define ECONV_STATEFUL_DECORATOR_MASK 0x00f00000
|
|
|
|
#define ECONV_XML_ATTR_QUOTE_DECORATOR 0x00100000
|
2008-08-14 10:48:41 -04:00
|
|
|
|
2008-08-26 08:55:14 -04:00
|
|
|
/* end of flags for rb_econv_open */
|
|
|
|
|
2008-08-14 10:48:41 -04:00
|
|
|
/* flags for rb_econv_convert */
|
2008-09-06 11:39:00 -04:00
|
|
|
#define ECONV_PARTIAL_INPUT 0x00010000
|
2008-09-09 12:27:02 -04:00
|
|
|
#define ECONV_AFTER_OUTPUT 0x00020000
|
2008-08-26 08:55:14 -04:00
|
|
|
/* end of flags for rb_econv_convert */
|
2008-08-14 10:48:41 -04:00
|
|
|
|
2007-08-25 00:14:26 -04:00
|
|
|
#endif /* RUBY_ENCODING_H */
|