~ubuntu-branches/ubuntu/intrepid/ruby1.9/intrepid-updates

« back to all changes in this revision

Viewing changes to include/ruby/encoding.h

  • Committer: Bazaar Package Importer
  • Author(s): Matthias Klose
  • Date: 2007-09-04 16:01:17 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20070904160117-i15zckg2nhxe9fyw
Tags: 1.9.0+20070830-2ubuntu1
* Sync from Debian; remaining changes:
  - Add -g to CFLAGS.
* Fixes build failure on ia64.
* Fixes build failure with gcc-4.2 on lpia.
* Robustify check for target_os, fixing build failure on lpia.
* Set Ubuntu maintainer address.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**********************************************************************
 
2
 
 
3
  encoding.h -
 
4
 
 
5
  $Author: matz $
 
6
  $Date: 2007-05-24 11:49:41 +0900 (Thu, 24 May 2007) $
 
7
  created at: Thu May 24 11:49:41 JST 2007
 
8
 
 
9
  Copyright (C) 2007 Yukihiro Matsumoto
 
10
 
 
11
**********************************************************************/
 
12
 
 
13
#ifndef RUBY_ENCODING_H
 
14
#define RUBY_ENCODING_H 1
 
15
 
 
16
#include "ruby/oniguruma.h"
 
17
 
 
18
#define ENCODING_INLINE_MAX 15
 
19
#define ENCODING_MASK (FL_USER8|FL_USER9|FL_USER10|FL_USER11)
 
20
#define ENCODING_SHIFT (FL_USHIFT+8)
 
21
#define ENCODING_SET(obj,i) do {\
 
22
    RBASIC(obj)->flags &= ~ENCODING_MASK;\
 
23
    RBASIC(obj)->flags |= i << ENCODING_SHIFT;\
 
24
} while (0)
 
25
#define ENCODING_GET(obj) ((RBASIC(obj)->flags & ENCODING_MASK)>>ENCODING_SHIFT)
 
26
 
 
27
typedef OnigEncodingType rb_encoding;
 
28
 
 
29
int rb_enc_to_index(rb_encoding*);
 
30
rb_encoding* rb_enc_get(VALUE);
 
31
rb_encoding* rb_enc_check(VALUE,VALUE);
 
32
void rb_enc_associate(VALUE, rb_encoding*);
 
33
void rb_enc_copy(VALUE, VALUE);
 
34
 
 
35
VALUE rb_enc_str_new(const char*, long len, rb_encoding*);
 
36
long rb_enc_strlen(const char*, const char*, rb_encoding*);
 
37
char* rb_enc_nth(const char*, const char*, int, rb_encoding*);
 
38
 
 
39
/* index -> rb_encoding */
 
40
rb_encoding* rb_enc_from_index(int idx);
 
41
 
 
42
/* name -> rb_encoding */
 
43
rb_encoding * rb_enc_find(const char *name);
 
44
 
 
45
/* encoding -> name */
 
46
#define rb_enc_name(enc) (enc)->name
 
47
 
 
48
/* encoding -> minlen/maxlen */
 
49
#define rb_enc_mbminlen(enc) (enc)->min_enc_len
 
50
#define rb_enc_mbmaxlen(enc) (enc)->max_enc_len
 
51
 
 
52
/* ptr,encoding -> mbclen */
 
53
int rb_enc_mbclen(const char*, rb_encoding*);
 
54
 
 
55
/* code,encoding -> codelen */
 
56
int rb_enc_codelen(int, rb_encoding*);
 
57
 
 
58
/* code,ptr,encoding -> write buf */
 
59
#define rb_enc_mbcput(c,buf,enc) ONIGENC_CODE_TO_MBC(enc,c,(UChar*)buf)
 
60
 
 
61
/* ptr,ptr,encoding -> codepoint */
 
62
#define rb_enc_codepoint(p,e,enc) ONIGENC_MBC_TO_CODE(enc,(UChar*)p,(UChar*)e) 
 
63
 
 
64
/* ptr, ptr, encoding -> prev_char */
 
65
#define rb_enc_prev_char(s,p,enc) onigenc_get_prev_char_head(enc,(UChar*)s,(UChar*)p)
 
66
 
 
67
#define rb_enc_isascii(c,enc) ONIGENC_IS_CODE_ASCII(c)
 
68
#define rb_enc_isalpha(c,enc) ONIGENC_IS_CODE_ALPHA(enc,c)
 
69
#define rb_enc_islower(c,enc) ONIGENC_IS_CODE_LOWER(enc,c)
 
70
#define rb_enc_isupper(c,enc) ONIGENC_IS_CODE_UPPER(enc,c)
 
71
#define rb_enc_isalnum(c,enc) ONIGENC_IS_CODE_ALNUM(enc,c)
 
72
#define rb_enc_isprint(c,enc) ONIGENC_IS_CODE_PRINT(enc,c)
 
73
#define rb_enc_isspace(c,enc) ONIGENC_IS_CODE_SPACE(enc,c)
 
74
#define rb_enc_isdigit(c,enc) ONIGENC_IS_CODE_DIGIT(enc,c)
 
75
 
 
76
int rb_enc_toupper(int c, rb_encoding *enc);
 
77
int rb_enc_tolower(int c, rb_encoding *enc);
 
78
ID rb_intern3(const char*, long, rb_encoding*);
 
79
 
 
80
#endif /* RUBY_ENCODING_H */